我有这个由其他人开发的Java Swings应用程序,它延迟了Windows Server 2008 r2 32 Bit上某些进程的执行,但它在Windows XP 32& Windows 7 32位。 我已经确认该应用程序运行在与Windows XP和Windows XP相同的JRE(32位版本)上。 Windows 7。
注意: 我已经在Windows XP和Windows 7中测试了延迟应用程序,并且没有遇到过这样的问题。 但是Windows Server 2008 r2(32位操作系统)在应用程序日志中会出现延迟。
以下是延迟交易的代码:
private Thread TID; // The Consumer thread
private Object q[]; // Queued Values for thread
private int nQueue; // Number of items in the Queue
private int dataStatus; // Status of the Queue
private long timeout;
private String myName;
private int MaxSize;
// legal Queue status values
final static int NONE = 0; // No data available
final static int NEW = 1; // New data available
final static int OVERRUN = 2; // Data overrun (queue overflow)
final static int SHUTDOWN = 3; // Data stream shutdown
DataItem(Thread t, String name, int Q, long timeo)
{
q = new Object[Q];
nQueue = 0;
TID = t;
timeout = timeo;
dataStatus = NONE;
myName = name;
MaxSize = Q;
}
DataItem(Thread t, String name, int Q)
{
this(t, name, Q, 10);
}
/** shorter version for a queue size of two (2) */
DataItem(Thread t, String name)
{
this(t, name, 2, 3000);
}
synchronized Object fetch(Trace log) throws DataStreamOverrun,
DataStreamShutdown,
DataStreamTimeout
{
Object r = null;
/* If nothing is waiting, we sleep.*/
if (dataStatus == NONE)
{
log.event("dataStatus :"+dataStatus);
try
{
long was = System.currentTimeMillis();
// wait();
log.event("was :"+was);
wait(timeout);
log.event("timeout :"+timeout);
if ((System.currentTimeMillis() - was) >= timeout)
throw new DataStreamTimeout();
}
catch (InterruptedException e){
log.event("SHUTDOWN :"+SHUTDOWN);
dataStatus = SHUTDOWN;
}
}
if(nQueue > 0)
{
log.event("--------- " + "Version ( " + MyPin.getVersion() +
" ) ---------");
log.event("Reading msg from stream : " + myName +
" size(" + nQueue + "/" + MaxSize + ")");
}
/* Data (or Status) has arrived so dispatch it. */
switch (dataStatus)
{
case NONE:
break;
case NEW:
r = q[0];
System.arraycopy(q, 1, q, 0, q.length - 1);
nQueue--;
break;
case OVERRUN:
dataStatus = NEW; // Next call will get the data
throw new DataStreamOverrun();
case SHUTDOWN:
throw new DataStreamShutdown();
}
if (nQueue == 0)
dataStatus = NONE;
return r;
}