public Object pop()
{
Object x;
if(Thread.interrupted())
return null;
x = extract();
if(x != null)
{
size--;
return x;
}
Object obj = putLock;
JVM INSTR monitorenter ;
waitingForTake++;
_L1:
x = extract();
if(x == null)
break MISSING_BLOCK_LABEL_79;
waitingForTake--;
size--;
return x;
putLock.wait();
goto _L1
InterruptedException ex;
ex;
waitingForTake--;
putLock.notify();
null;
obj;
JVM INSTR monitorexit ;
return;
Exception exception;
exception;
throw exception;
}源代码应该怎么写呢?麻烦各位帮帮忙,谢谢。
{
Object x;
if(Thread.interrupted())
return null;
x = extract();
if(x != null)
{
size--;
return x;
}
Object obj = putLock;
JVM INSTR monitorenter ;
waitingForTake++;
_L1:
x = extract();
if(x == null)
break MISSING_BLOCK_LABEL_79;
waitingForTake--;
size--;
return x;
putLock.wait();
goto _L1
InterruptedException ex;
ex;
waitingForTake--;
putLock.notify();
null;
obj;
JVM INSTR monitorexit ;
return;
Exception exception;
exception;
throw exception;
}源代码应该怎么写呢?麻烦各位帮帮忙,谢谢。
{
if(Thread.interrupted())
return null;
Object x = extract();
if(x != null)
{
size--;
return x;
}
synchronized(putLock)
{
waitingForTake++;
for(;;)
{
x = extract();
if (x !=null)
{
waitingForTake--;
size--;
return x;
}
try
{
putLock.wait();
}
catch(InterrupedException ex)
{
waitingForTak--;
putLock.notify();
return null;
}
}
}
}