mirror of
https://github.com/autc04/Retro68.git
synced 2024-12-04 16:50:57 +00:00
28 lines
489 B
Java
28 lines
489 B
Java
// Test that Thread.holdsLock() works.
|
|
|
|
class Lock {}
|
|
|
|
public class Thread_HoldsLock
|
|
{
|
|
static Lock lock = new Lock();
|
|
|
|
public static void main(String args[]) throws InterruptedException
|
|
{
|
|
Thread_HoldsLock thl = new Thread_HoldsLock();
|
|
|
|
thl.check();
|
|
synchronized (lock)
|
|
{
|
|
thl.check();
|
|
}
|
|
thl.check();
|
|
}
|
|
|
|
public void check()
|
|
{
|
|
Thread this_thread = Thread.currentThread();
|
|
System.out.println(this_thread.holdsLock(lock));
|
|
}
|
|
}
|
|
|