private static void attemptThreadControl(long threadId, Runnable r){ //(get lock) boolean tookLock = false; if(!control.isHeldByCurrentThread()){ control.lock(); tookLock = true; } //(perform action) attemptThreadControlThreadsafe(threadId); if(threadId == currentThread){ r.run(); } else { queueTask(threadId, r); } //(release lock) assert control.isHeldByCurrentThread(); if(tookLock){ control.unlock(); } }
assert ! threadsWaiting.isEmpty(); control.lock(); attemptThreadControlThreadsafe(-1); control.unlock();
private static void attemptThreadControl(long threadId, Runnable r){ //(get lock) boolean tookLock = false; if(!control.isHeldByCurrentThread()){ control.lock(); tookLock = true; } //(perform action) attemptThreadControlThreadsafe(threadId); if(threadId == currentThread){ r.run(); } else { queueTask(threadId, r); } //(release lock) assert control.isHeldByCurrentThread(); if(tookLock){ control.unlock(); } }
private static void attemptThreadControl(long threadId, Runnable r){ //(get lock) boolean tookLock = false; if(!control.isHeldByCurrentThread()){ control.lock(); tookLock = true; } //(perform action) attemptThreadControlThreadsafe(threadId); if(threadId == currentThread){ r.run(); } else { queueTask(threadId, r); } //(release lock) assert control.isHeldByCurrentThread(); if(tookLock){ control.unlock(); } }
private static void attemptThreadControl(long threadId, Runnable r){ //(get lock) boolean tookLock = false; if(!control.isHeldByCurrentThread()){ control.lock(); tookLock = true; } //(perform action) attemptThreadControlThreadsafe(threadId); if(threadId == currentThread){ r.run(); } else { queueTask(threadId, r); } //(release lock) assert control.isHeldByCurrentThread(); if(tookLock){ control.unlock(); } }
assert !threadsWaiting.isEmpty(); control.lock(); attemptThreadControlThreadsafe(-1); control.unlock();
assert !threadsWaiting.isEmpty(); control.lock(); attemptThreadControlThreadsafe(-1); control.unlock();
assert !threadsWaiting.isEmpty(); control.lock(); attemptThreadControlThreadsafe(-1); control.unlock();