[concurrency-interest] Fwd: ThreadPoolTask

David Holmes dcholmes at optusnet.com.au
Mon Jul 10 02:34:43 EDT 2006


> or check out the last code example in the following topic:
> http://forum.springframework.org/showthread.php?t=26194&highlight=repeater
> The parser is a component with a InputChannel (Takeable) that contains
> messages and it also has 2 output channels (one for parsed messages,
> and one for errors).
> The parserrepeater is hooked up to the parser. The parser exposes an
> axle (the parse method that blocks if no message are available on the
> input channel) and the parserrepeater is the engine you hook up to
> that axle. It gives a very clear design imho.

So if I'm understanding this right, what you have done is to invert the
classic producer consumer loop so that instead of having a consumer thread

   while ((parseTask = channel.take()) != STOP_TASK) { // just an example
       executeor.execute(new ParsingTask(parseTask));

Your "executor" instead has worker threads that executes the same task
instance that has a blocking run() method of the form:

   while ((parseTask = channel.take()) != STOP_TASK) { // just an example

Is that right?


More information about the Concurrency-interest mailing list