void doWait() { while (! done) { park(); } }
public boolean block() { if (isReleasable()) return true; else if (!timed) LockSupport.park(this); else if (nanos > 0) LockSupport.parkNanos(this, nanos); return isReleasable(); } }
public boolean block() { if (isReleasable()) return true; else if (!timed) LockSupport.park(this); else if (nanos > 0L) LockSupport.parkNanos(this, nanos); return isReleasable(); } }
public void run() { while (! done) { park(); } }
void parkThread() { LockSupport.park(); }
/** * Convenience method to park and then check if interrupted * * @return {@code true} if interrupted */ private final boolean parkAndCheckInterrupt() { LockSupport.park(this); return Thread.interrupted(); }
/** * Convenience method to park and then check if interrupted * * @return {@code true} if interrupted */ private final boolean parkAndCheckInterrupt() { LockSupport.park(this); return Thread.interrupted(); }
private void ensureCacheToDB(int id) { handler.removeMessages(id); if (handlingId.get() == id) { parkThread = Thread.currentThread(); handler.sendEmptyMessage(WHAT_CLEAN_LOCK); LockSupport.park(); } else { syncCacheToDB(id); } }
protected void readMessages() { _readMessages(); LockSupport.park(); }
protected void readMessages() { _readMessages(); LockSupport.park(); }
@Override public void awaitUninterruptibly() { boolean interrupted = false; while (!isSignalled()) { if (Thread.interrupted()) interrupted = true; LockSupport.park(); } if (interrupted) Thread.currentThread().interrupt(); checkAndClear(); }
@Override public void updateCompleted(int id, long total) { this.cachedDatabase.updateCompleted(id, total); if (isNoNeedUpdateToRealDB(id)) { handler.removeMessages(id); if (handlingId.get() == id) { parkThread = Thread.currentThread(); handler.sendEmptyMessage(WHAT_CLEAN_LOCK); LockSupport.park(); this.realDatabase.updateCompleted(id, total); } } else { this.realDatabase.updateCompleted(id, total); } freeToDBIdList.remove((Integer) id); }
@Test public void testServer() { start(); LockSupport.park(); }
@Test public void testConnClient() throws Exception { testConnClient(1, "", 1, true); LockSupport.park(); }
"My thread" prio=10 tid=0x00007fffec082800 nid=0x17e8 waiting on condition [0x00007ffff14eb000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000007d6a33d30> (a java.util.concurrent.locks.ReentrantLock$FairSync) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156) at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:842) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1178) at java.util.concurrent.locks.ReentrantLock$FairSync.lock(ReentrantLock.java:201) at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:262) at LockTest.reentrantLock(LockTest.java:22) at LockTest$2.run(LockTest.java:25) at java.lang.Thread.run(Thread.java:662)
LockSupport.park(this);
@Override public void await() throws InterruptedException { while (!isSignalled()) { checkInterrupted(); LockSupport.park(); } checkAndClear(); }
@Test public void subTest() { RedisManager.I.subscribe(listenerDispatcher.getSubscriber(), "/hello/123"); RedisManager.I.subscribe(listenerDispatcher.getSubscriber(), "/hello/124"); LockSupport.park(); }
@Override public void run() { assert backgroundThread == null : "A thread is already running " + backgroundThread; backgroundThread = Thread.currentThread(); startupLatch.release(); try { do { AsyncEvent events = STACK_UPDATER.getAndSet( this, END_SENTINEL ); process( events ); if ( stack == END_SENTINEL && !shutdown ) { LockSupport.park( this ); } } while ( !shutdown ); AsyncEvent events = STACK_UPDATER.getAndSet( this, SHUTDOWN_SENTINEL ); process( events ); } finally { backgroundThread = null; shutdownLatch.release(); } }
public static void main(String[] args) { ServiceRegistry registry = ServiceRegistryFactory.create(); registry.syncStart(); registry.register(ServerNodes.gs()); registry.register(ServerNodes.gs()); registry.deregister(ServerNodes.gs()); LockSupport.park(); }