This is my first post, and your kindness is requested
[Edit:Ok its first in OO, Patterns section ]
I have a java application that runs in an eternal while loop. I want to pass messages to my application to e.g. gracefully shutdown, move to init state, current number of processed counts. Essentially I am looking for a pattern wherein there is a control thread that passes messages to business/Main thread and the Main thread asynchronously handles the message and updates the control thread. The control thread can have aribtrary IO mechanism.
There were two candidates that matched closed to my requirements
1. Observer Pattern
2. Task Pattern
From my understanding, observer pattern has (simplex) unidirectional information flow(although at oodesign, they advocate notify() can be implemented in push/pull mechanism with which i disagree), and I am more interested in a halfduplex/fullduplex.
Task Pattern looks promising candidate and can be used to monitor long running tasks (with appropriate interfaces) but I was not able to find detailed literature on the web for it.
I am here to seek some suggestions regarding the best pattern for implementing my problem.
I don't think that there is any pattern that will completely address your problem. At first you should clearly describe your requirements. Once it is done think of how to implement them and as far as I understand you need to think about threading issues first, but not about how to name the pattern.
Try to answer the following questions:
1) What is the complete set of operations you want to implement?
2) How should they interact with each other? (e.g. whether they can interfere or must be called sequentally?)
3) Should they be synchronous or asynchronous?