<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19088"></HEAD>
<BODY>
<DIV><SPAN class=890042520-01082011><FONT color=#0000ff size=2 face=Arial>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.</FONT></SPAN></DIV>
<DIV><SPAN class=890042520-01082011><FONT color=#0000ff size=2
face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=890042520-01082011><FONT color=#0000ff size=2
face=Arial>David</FONT></SPAN></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #0000ff 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px">
<DIV dir=ltr class=OutlookMessageHeader align=left><FONT size=2
face=Tahoma>-----Original Message-----<BR><B>From:</B> Ashwin Jayaprakash
[mailto:ashwin.jayaprakash@gmail.com]<BR><B>Sent:</B> Tuesday, 2 August 2011
6:06 AM<BR><B>To:</B> dholmes@ieee.org<BR><B>Cc:</B>
concurrency-interest@cs.oswego.edu<BR><B>Subject:</B> Re:
[concurrency-interest] j.u.c.Phaser tutorial?<BR><BR></FONT></DIV>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.<BR><BR><BR>
<DIV class=gmail_quote>On Sun, Jul 31, 2011 at 3:47 PM, David Holmes <SPAN
dir=ltr><<A
href="mailto:davidcholmes@aapt.net.au">davidcholmes@aapt.net.au</A>></SPAN>
wrote:<BR>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote><U></U>
<DIV>
<DIV><SPAN><FONT color=#0000ff size=2 face=Arial>Ashwin,</FONT></SPAN></DIV>
<DIV><SPAN><FONT color=#0000ff size=2 face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN><FONT color=#0000ff size=2 face=Arial>> <FONT color=#000000
size=3 face="Times New Roman">I learned later that the arriveAndDeregister()
method makes sense only when you create a hierarchy of
phasers</FONT></FONT></SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN><FONT color=#0000ff size=2 face=Arial>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.</FONT></SPAN></DIV>
<DIV><SPAN><FONT color=#0000ff size=2 face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN><FONT color=#0000ff size=2 face=Arial>David
Holmes</FONT></SPAN><BR></DIV></DIV></BLOCKQUOTE></DIV><BR><BR></BLOCKQUOTE></BODY></HTML>