[concurrency-interest] Phaser question

Mohan Radhakrishnan mohanr at fss.co.in
Fri Sep 16 02:08:37 EDT 2011


Hi,

       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
advancing

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.

 

Thanks,

Mohan

 

 

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

        Runnable tsk = new Runnable(){

 

                        @Override

                        public void run() {

                            Platform.runLater(new Runnable() {

                                public void run() {

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

                                }

                            });

                        }

                    };

        tasks.add( tsk );

 

        phaser.register();

        for ( final Runnable task : tasks ) {

          phaser.register();

          new Thread() {

            public void run() {

                try {

                    sleep(1500);

                } catch (InterruptedException e) {

                    //Print info.                }

                do {

                    task.run();

                    phaser.arriveAndAwaitAdvance(); //Finish phase

                } while (!phaser.isTerminated());

            }

          }.start();

        }



DISCLAIMER:
==========================================================================================================================================================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/788d475e/attachment.html>


More information about the Concurrency-interest mailing list