public void initializeWorker( @NotNull CallbackCaller<T> callbackCaller ) { log.debug( "initializeWorker " + callbackCaller ); workerThread = new Thread( new AsyncWorker<T>( this, callbackCaller ), NAME_PREFIX + callbackCaller.getDescription() + ' ' + hashCode() ); workerThread.start(); initialized = true; }
@Override public void run() { log.debug( "up and running" ); //noinspection InfiniteLoopStatement while ( true ) { if ( Thread.currentThread().isInterrupted() ) { log.debug( "Thread has been interrupted --> exiting" ); return; } try { log.debug( "waiting for next callback" ); T callback = support.waitForNextCallback(); log.debug( "got callback" ); Object returnValue; synchronized ( support ) { returnValue = execute( callback ); } log.debug( "executed" ); support.acknowledge( callback, returnValue ); log.debug( "acknowledged" ); } catch ( InterruptedException ignore ) { log.debug( "Thread has been interrupted --> exiting" ); return; } } }
@Override public void run() { log.debug( "up and running" ); //noinspection InfiniteLoopStatement while ( true ) { if ( Thread.currentThread().isInterrupted() ) { log.debug( "Thread has been interrupted --> exiting" ); return; } try { log.debug( "waiting for next callback" ); T callback = support.waitForNextCallback(); log.debug( "got callback" ); Object returnValue; synchronized ( support ) { returnValue = execute( callback ); } log.debug( "executed" ); support.acknowledge( callback, returnValue ); log.debug( "acknowledged" ); } catch ( InterruptedException ignore ) { log.debug( "Thread has been interrupted --> exiting" ); return; } } }
public void initializeWorker( @Nonnull CallbackCaller<T> callbackCaller ) { log.debug( "initializeWorker " + callbackCaller ); workerThread = new Thread( new AsyncWorker<T>( this, callbackCaller ), NAME_PREFIX + callbackCaller.getDescription() + ' ' + hashCode() ); workerThread.start(); initialized = true; }