Wrap text
Report abuse
|
|
try {
this.checkLocks = true;
if (DEBUG) System.out.println("thread " + Thread.currentThread() + " trying to kill");
while (!(currentThread.lock.tryLock() && this.lock.tryLock())) {
if (currentThread.lock.isHeldByCurrentThread()) currentThread.lock.unlock();
}
currentThread.pollThreadEvents();
if (DEBUG) System.out.println("thread " + Thread.currentThread() + " succeeded with kill");
killed = true;
threadImpl.interrupt(); // break out of wait states and blocking IO
} finally {
if (currentThread.lock.isHeldByCurrentThread()) currentThread.lock.unlock();
if (this.lock.isHeldByCurrentThread()) this.lock.unlock();
this.checkLocks = false;
}
try {
threadImpl.join();
} catch (InterruptedException ie) {
// we were interrupted, check thread events again
currentThread.pollThreadEvents();
} catch (ExecutionException ie) {
// we were interrupted, check thread events again
currentThread.pollThreadEvents();
}
return this;
|