[concurrency-interest] Please comment on thisapproach

David Holmes dholmes at dltech.com.au
Wed May 4 23:10:57 EDT 2005


> 2. Back in my native Win32 days, I'd use a sentinel Event and
> WaitForMultipleObjects to be notified that I should fall out the
> bottom of a thread. There's probably something like that in the
> concurrent API,

No there is nothing like that in the concurrent API - neither a sentinel
event nor waitForMultipleObjects :)
 
I was referring to simply defining a special Object that you use as a
marker:

   static final Object STOP = new Object();


   public void stop() {
          q.add(STOP);
          thread.join(); // if you really need this
          ...
  }

  public void run() {
    Object obj;
    while ((obj = queue.take()) != STOP) {
      // process obj
   }
  }
 
Cheers,
David Holmes



More information about the Concurrency-interest mailing list