summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.lang/Thread_HoldsLock.java
blob: 62119a16083d6537b44580a4a10227b117d10d5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// 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));
  }
}