[concurrency-interest] Fwd: Fwd: ThreadPoolTask

Peter Veentjer alarmnummer at gmail.com
Mon Jul 10 02:41:21 EDT 2006


---------- Forwarded message ----------
From: Peter Veentjer <alarmnummer at gmail.com>
Date: Jul 10, 2006 8:40 AM
Subject: Re: [concurrency-interest] Fwd: ThreadPoolTask
To: dholmes at ieee.org


The parseSingleMessage looks like this:

void parseSingleMessage(){
    Page page = pageInputChannel.take();
    try{
         ParsedPage parsedPage = parse(page);
         successOutputChannel.put(parsedPage);
    }catch(ParseException ex){
          errorOutputChannel.put(...);
    }
}

The parser doesn't do any looping itself.

This makes it very easy to test such components.

> 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
> doing:
>
>    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
>        parse(parseTask);
>    }
>
> Is that right?
>
> Cheers,
> David
>
>


More information about the Concurrency-interest mailing list