Methods Summary |
---|
public static void | main(java.lang.String[] args)
junit.textui.TestRunner.run (suite());
|
public static junit.framework.Test | suite()
return new TestSuite(LockSupportTest.class);
|
public void | testPark()park is released by unpark occurring after park
Thread t = new Thread(new Runnable() {
public void run() {
try {
LockSupport.park();
} catch(Exception e){
threadUnexpectedException();
}
}
});
try {
t.start();
Thread.sleep(SHORT_DELAY_MS);
LockSupport.unpark(t);
t.join();
}
catch(Exception e) {
unexpectedException();
}
|
public void | testPark2()park is released by unpark occurring before park
Thread t = new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(SHORT_DELAY_MS);
LockSupport.park();
} catch(Exception e){
threadUnexpectedException();
}
}
});
try {
t.start();
LockSupport.unpark(t);
t.join();
}
catch(Exception e) {
unexpectedException();
}
|
public void | testPark3()park is released by interrupt
Thread t = new Thread(new Runnable() {
public void run() {
try {
LockSupport.park();
threadAssertTrue(Thread.interrupted());
} catch(Exception e){
threadUnexpectedException();
}
}
});
try {
t.start();
Thread.sleep(SHORT_DELAY_MS);
t.interrupt();
t.join();
}
catch(Exception e) {
unexpectedException();
}
|
public void | testPark4()park returns if interrupted before park
final ReentrantLock lock = new ReentrantLock();
lock.lock();
Thread t = new Thread(new Runnable() {
public void run() {
try {
lock.lock();
LockSupport.park();
} catch(Exception e){
threadUnexpectedException();
}
}
});
try {
t.start();
t.interrupt();
lock.unlock();
t.join();
}
catch(Exception e) {
unexpectedException();
}
|
public void | testParkNanos()parkNanos times out if not unparked
Thread t = new Thread(new Runnable() {
public void run() {
try {
LockSupport.parkNanos(1000);
} catch(Exception e){
threadUnexpectedException();
}
}
});
try {
t.start();
t.join();
}
catch(Exception e) {
unexpectedException();
}
|
public void | testParkUntil()parkUntil times out if not unparked
Thread t = new Thread(new Runnable() {
public void run() {
try {
long d = new Date().getTime() + 100;
LockSupport.parkUntil(d);
} catch(Exception e){
threadUnexpectedException();
}
}
});
try {
t.start();
t.join();
}
catch(Exception e) {
unexpectedException();
}
|