boolean waited = false;
while(_head == null && (waitTime == 0 || !waited)) {
if(_doDispose == _disposeId) {
_doDispose = null;
throw (DisposedException)
new DisposedException().initCause(_throwable);
}
// notify sync queues
notifyAll();
try {
// wait for new job
wait(waitTime);
}
catch(InterruptedException interruptedException) {
throw new com.sun.star.uno.RuntimeException(getClass().getName() + ".removeJob - unexpected:" + interruptedException);
}
// signal that we have already waited once
waited = true;
}
if(_head != null) {
Job current = _head;
_head = _head._next;
if(_head == null)
_tail = null;
job = current;
_active = true;
}
}
// always wait for asynchron jobqueue to be finished !
if(job != null && _async_jobQueue != null) {
synchronized(_async_jobQueue) {
// wait for async queue to be empty and last job to be done
while(_async_jobQueue._active || _async_jobQueue._head != null) {
if(DEBUG) System.err.println("waiting for async:" + _async_jobQueue._head + " " + _async_jobQueue._worker_thread);
if(_doDispose == _disposeId) {
_doDispose = null;
throw (DisposedException)
new DisposedException().initCause(_throwable);
}
try {
_async_jobQueue.wait();
}