Make LinkedTransferQueue also work in java5 envs.

This commit is contained in:
Norman Maurer 2011-12-11 11:53:00 +01:00
parent 36e8c4e8f2
commit 3359a565c2

View File

@ -723,12 +723,21 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
}
else if (timed) {
long now = System.nanoTime();
if ((nanos -= now - lastTime) > 0)
LockSupport.parkNanos(this, nanos);
if ((nanos -= now - lastTime) > 0) {
// Use LockSupport.parkNanose(nanos) to make it compatible with java5
//
//LockSupport.parkNanos(this, nanos);
LockSupport.parkNanos(nanos);
}
lastTime = now;
}
else {
LockSupport.park(this);
// Use LockSupport.park() to make it compatible with java5
//
//LockSupport.park(this);
LockSupport.park();
}
}
}