//Get a reference to the main thread.
final Thread mainThread = Thread.currentThread();
//Create a thread-bound processing.
final ThreadBoundReactor reactor =
new ThreadBoundReactor(new Runnable() {
@Override
public void run() {
//Interrupt the main thread when there are messages to process
mainThread.interrupt();
}
});
//Create an blades that uses the thread-bound processing.
final SampleThreadBoundBlade threadBoundBlade = new SampleThreadBoundBlade(reactor);
//Terminate the blades.
new SOp<Void>("finBlade", threadBoundBlade.getReactor()) {
@Override
protected Void processSyncOperation(RequestImpl _requestImpl) throws Exception {
threadBoundBlade.fin();
return null;
}
}.signal();
//Process messages when this thread is interrupted.
while (true) {
try {
//Wait for an interrupt.
Thread.sleep(60000);
} catch (InterruptedException e) {
//Process messages when the main thread is interrupted.
reactor.run();
}
}
}