test/hotspot/jtreg/vmTestbase/nsk/share/locks/MonitorLockingThread.java
changeset 59021 cfc7bb9a5a92
parent 49934 44839fbb20db
equal deleted inserted replaced
59020:aebd72de84b0 59021:cfc7bb9a5a92
    76             /*
    76             /*
    77              * Wait when blockedThread's state will switch to 'BLOCKED' (at that moment monitor contention
    77              * Wait when blockedThread's state will switch to 'BLOCKED' (at that moment monitor contention
    78              * should already occur) and then force MonitorLockingThread to release lock
    78              * should already occur) and then force MonitorLockingThread to release lock
    79              */
    79              */
    80             while (blockedThread.getState() != Thread.State.BLOCKED)
    80             while (blockedThread.getState() != Thread.State.BLOCKED)
    81                 yield();
    81                 Thread.yield();
    82 
    82 
    83             lockingThread.releaseLock();
    83             lockingThread.releaseLock();
    84         }
    84         }
    85     }
    85     }
    86 
    86 
    96 
    96 
    97     public void run() {
    97     public void run() {
    98         synchronized (lockToHold) {
    98         synchronized (lockToHold) {
    99             holdsLock = true;
    99             holdsLock = true;
   100             while (isRunning)
   100             while (isRunning)
   101                 yield();
   101                 Thread.yield();
   102         }
   102         }
   103         holdsLock = false;
   103         holdsLock = false;
   104     }
   104     }
   105 
   105 
   106     public void releaseLock() {
   106     public void releaseLock() {
   107         isRunning = false;
   107         isRunning = false;
   108         while (holdsLock)
   108         while (holdsLock)
   109             yield();
   109             Thread.yield();
   110     }
   110     }
   111 
   111 
   112     public void acquireLock() {
   112     public void acquireLock() {
   113         start();
   113         start();
   114         while (!holdsLock)
   114         while (!holdsLock)
   115             yield();
   115             Thread.yield();
   116     }
   116     }
   117 }
   117 }