break; LockSupport.parkUntil(this, abstime); if ((interruptMode = checkInterruptWhileWaiting(node)) != 0) break;
break; LockSupport.parkUntil(this, abstime); if ((interruptMode = checkInterruptWhileWaiting(node)) != 0) break;
private long runAllDue() throws InterruptedException { long nextRunTime = 0; TimedTask task; while ((task = scheduledTasks.poll(60, java.util.concurrent.TimeUnit.SECONDS)) != null) { if (!task.isDue(currentTimeMillis())) { parkUntil(task.nextRuntime()); } /** * Sechedule the task for execution. */ if (!queue.offer(task, 5, java.util.concurrent.TimeUnit.SECONDS)) { saturationPolicy.dealWith(task); } if (task.calculateNextRuntime()) { scheduledTasks.offer(task); } } return nextRunTime; }
"main" #1 prio=5 os_prio=0 tid=0x0000000002b20800 nid=0x2aa8 waiting on condition [0x0000000002a2f000] java.lang.Thread.State: TIMED_WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x000000076b007220> (a java.time.LocalTime) at java.util.concurrent.locks.LockSupport.parkUntil(LockSupport.java:256) …
private void sleepMillis(long millis) { long deadline = System.currentTimeMillis() + millis; while (System.currentTimeMillis() < deadline && !shutdown) LockSupport.parkUntil(cleanupSleepingHandle, deadline); }
public final void parkUntil(long expires) { if (! _isParked.get()) return; try { Thread.interrupted(); LockSupport.parkUntil(expires); } finally { _isParked.set(false); } }
boolean get() { _thread = Thread.currentThread(); try { long expire = System.currentTimeMillis() + 60 * 1000L; while (! _isDone && System.currentTimeMillis() < expire) { LockSupport.parkUntil(expire); } return _isValue; } finally { _thread = null; } } }
LocalTime target = LocalTime.of(12, 50).minusSeconds(60); long deadLine = target.atDate(LocalDate.now()).atZone(ZoneId.systemDefault()) .toInstant().toEpochMilli(); while(System.currentTimeMillis() < deadLine) { // in case you want to support interruption: if(Thread.interrupted()) throw new InterruptedException(); LockSupport.parkUntil(target, deadLine); }
public void block(long blockSequence) { long expire = System.currentTimeMillis() + _timeout; Thread thread = Thread.currentThread(); _thread = thread; try { while (_readySequence < blockSequence && (System.currentTimeMillis() < expire)) { LockSupport.parkUntil(expire); } } catch (Exception e) { log.log(Level.FINER, e.toString(), e); } finally { _thread = null; } }
LockSupport.parkUntil(expires); } while (System.currentTimeMillis() < expires);
final void park(long expires) { Thread thread = _thread; while (_thread != null && CurrentTime.getCurrentTimeActual() < expires) { try { Thread.interrupted(); LockSupport.parkUntil(thread, expires); } catch (Exception e) { } } /* if (_thread != null) { System.out.println("TIMEOUT:" + thread); Thread.dumpStack(); } */ _thread = null; } }
boolean waitFor(long timeout) { _thread = Thread.currentThread(); long now = CurrentTime.getCurrentTimeActual(); long expires = now + timeout; while (! _isResult.get() && CurrentTime.getCurrentTimeActual() <= expires) { try { Thread.interrupted(); LockSupport.parkUntil(expires); } catch (Exception e) { } } _thread = null; return _isResult.get(); }
Stream<List<MediaFeedData>> stream = StreamSupport.stream( new Spliterators.AbstractSpliterator<List<MediaFeedData>>(Long.MAX_VALUE, 0) { long lastTime=System.currentTimeMillis(); @Override public boolean tryAdvance(Consumer<? super List<MediaFeedData>> action) { if(quitCondition()) return false; List<MediaFeedData> feedDataList = null; while (feedDataList == null) { lastTime+=TimeUnit.SECONDS.toMillis(2); while(System.currentTimeMillis()<lastTime) LockSupport.parkUntil(lastTime); try { feedDataList=newData(); } catch (InstagramException e) { notifyError(e.getMessage()); if(QUIT_ON_EXCEPTION) return false; } } action.accept(feedDataList); return true; } }, false);
public RpcResult awaitForResponse() { RpcResult rpcResult = this.result.get(); if (rpcResult != null) { return rpcResult; } Thread currentThread = Thread.currentThread(); if (!awaitThread.compareAndSet(null, currentThread)) { throw new SoaException(RpcErrorCode.TIMEOUT, "cannot await twice", new TimeoutException()); } while (result.get() == null) { LockSupport.parkUntil(System.currentTimeMillis() + 10000); } rpcResult = this.result.get(); if (rpcResult == null) { rpcResult = RpcResult.timeout(req); } return rpcResult; } }
private ResultState waitFor(long timeout) { _thread = Thread.currentThread(); long now = CurrentTime.getCurrentTimeActual(); long expires = now + timeout; while (_resultState == ResultState.UNSET && CurrentTime.getCurrentTimeActual() < expires) { try { Thread.interrupted(); LockSupport.parkUntil(expires); } catch (Exception e) { } } _thread = null; return _resultState; }
private long runAllDue() throws InterruptedException { long nextRunTime = 0; TimedTask task; while ((task = scheduledTasks.poll(60, java.util.concurrent.TimeUnit.SECONDS)) != null) { if (!task.isDue(currentTimeMillis())) { parkUntil(task.nextRuntime()); } /** * Sechedule the task for execution. */ if (!queue.offer(task, 5, java.util.concurrent.TimeUnit.SECONDS)) { saturationPolicy.dealWith(task); } if (task.calculateNextRuntime()) { scheduledTasks.offer(task); } } return nextRunTime; }
@Override public void run() { long nextRunMillis = System.currentTimeMillis(); while (nodeEngine.isActive()) { LockSupport.parkUntil(nextRunMillis); nextRunMillis = samplerPeriodMillis; sample(executor.getPartitionOperationRunners(), partitionSpecificSamples); sample(executor.getGenericOperationRunners(), genericSamples); } }
@Override public void run() { long nextRunMillis = System.currentTimeMillis(); while (nodeEngine.isActive()) { LockSupport.parkUntil(nextRunMillis); nextRunMillis = samplerPeriodMillis; sample(executor.getPartitionOperationRunners(), partitionSpecificSamples); sample(executor.getGenericOperationRunners(), genericSamples); } }
try { Thread.interrupted(); LockSupport.parkUntil(expires); } catch (Exception e) {
private MemberId findCoreMemberToCopyFrom() { while ( true ) { try { MemberId memberId = connectionStrategy.coreMember(); log.info( "Server starting, connecting to core server %s", memberId ); return memberId; } catch ( CoreMemberSelectionException ex ) { log.info( "Failed to connect to core server. Retrying in %d ms.", timeout.getMillis() ); LockSupport.parkUntil( timeout.getMillis() + System.currentTimeMillis() ); timeout.increment(); } } }