Hi All,
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.
Regards,
Nabeel