[concurrency-interest] Phaser question

Mohan Radhakrishnan mohanr at fss.co.in
Fri Sep 16 04:53:53 EDT 2011

Ok. I did what you suggested that using a latch. This is not a JavaFX
project but a way of showing a simulation of what the Phaser is doing.






From: concurrency-interest-bounces at cs.oswego.edu
[mailto:concurrency-interest-bounces at cs.oswego.edu] On Behalf Of Joe
Sent: Friday, September 16, 2011 12:29 PM
To: concurrency-interest
Subject: Re: [concurrency-interest] Phaser question


I suggest not advancing the phaser until the associated JavaFX task has
completed.  Otherwise, the phaser will stop too soon.


Looking at your sample code, where most of the work happens in
JavaFX-land, I'm wondering if the JavaFX animation timeline support
might be a better match for this than a phaser running in a background




On Thu, Sep 15, 2011 at 11:08 PM, Mohan Radhakrishnan wrote:


	       My code using the Phaser works the first time. I think
here when the onAdvance method is overridden (  return phase >= 2 ||
registeredParties == 0; )  I see log messages showing that the Phase is

	but I suspect that since the Platform.runLater is a separate
thread it does not execute the task the second and third time.


	Even though this is not strictly Phaser code only I am trying to
understand if any thread co-ordination is required here.






	        List<Runnable> tasks = new ArrayList<Runnable>();

	        Runnable tsk = new Runnable(){



	                        public void run() {

	                            Platform.runLater(new Runnable() {

	                                public void run() {

	                                    //JavaFX animate works fine
the first time but does not iterate.





	        tasks.add( tsk );



	        for ( final Runnable task : tasks ) {


	          new Thread() {

	            public void run() {

	                try {


	                } catch (InterruptedException e) {

	                    //Print info.                }

	                do {


	                    phaser.arriveAndAwaitAdvance(); //Finish

	                } while (!phaser.isTerminated());




==========================================================================================================================================================The information contained in this e-mail message may be privileged and/or confidential and protected from disclosure under applicable law. It is intended only for the individual to whom or entity to which it is addressed as shown at the beginning of the message. If the reader of this message is not the intended recipient, or if the employee or agent responsible for delivering the message is not an employee or agent of the intended recipient, you are hereby notified that any review, dissemination,distribution, use, or copying of this message is strictly prohibited. If you have received this message in error, please notify us immediately by return e-mail and permanently delete this message and your reply to the extent it includes this message. Any views or opinions presented in this message or attachments are those of the author and do not necessarily represent those of the Company. All e-mails and attachments sent and received are subject to monitoring, reading, and archival by the Company.==========================================================================================================================================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20110916/b47c47c1/attachment.html>

More information about the Concurrency-interest mailing list