atom feed6 messages in edu.oswego.cs.concurrency-interestRe: [concurrency-interest] j.u.c.Phas...
FromSent OnAttachments
Ashwin JayaprakashJul 29, 2011 10:29 am 
Ashwin JayaprakashJul 31, 2011 12:40 pm 
David HolmesJul 31, 2011 3:47 pm 
Ashwin JayaprakashAug 1, 2011 1:06 pm 
David HolmesAug 1, 2011 1:27 pm 
Ashwin JayaprakashAug 1, 2011 8:47 pm 
Subject:Re: [concurrency-interest] j.u.c.Phaser tutorial?
From:David Holmes (davi@aapt.net.au)
Date:Aug 1, 2011 1:27:21 pm
List:edu.oswego.cs.concurrency-interest

Not sure what you mean by "the end". The main thread calls arriveAndDeregister to allow the first release of the barrier to occur while at the same time removing itself from future cycles of the barrier (so the main processing loops only require the N worker threads to meet at the barrier). If the main thread didn't deregister then the N worker threads would block at the barrier waiting for a non-existent N+1 thread to turn up.

David -----Original Message----- From: Ashwin Jayaprakash [mailto:ashw@gmail.com] Sent: Tuesday, 2 August 2011 6:06 AM To: dhol@ieee.org Cc: conc@cs.oswego.edu Subject: Re: [concurrency-interest] j.u.c.Phaser tutorial?

Why doesn't the main thread just call arrive() at the end? I guess only for clarity - to show that only x worker threads (minus 1 starter thread) are required for the processing.

On Sun, Jul 31, 2011 at 3:47 PM, David Holmes <davi@aapt.net.au> wrote:

Ashwin,

> I learned later that the arriveAndDeregister() method makes sense only when you create a hierarchy of phasers

Not so. arriveAndDeregister is typically used by the main thread when the phaser acts as both a cyclic barrier and a starting latch. You create the phaser for N+1 threads and have all workers wait on the phaser in a loop. The main thread is needed to release the phaser the first time so that all workers have been created but thereafter is not needed so it can arrive and deregister.