[concurrency-interest] Phaser question

David Holmes davidcholmes at aapt.net.au
Sun Sep 18 06:27:12 EDT 2011


Maybe I'm missing something but your main thread is registered with the
Phaser but never arrives, so any of the task threads calling
arriveAndAwaitAdvance would block forever.

David Holmes
  -----Original Message-----
  From: concurrency-interest-bounces at cs.oswego.edu
[mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Mohan
Radhakrishnan
  Sent: Friday, 16 September 2011 4:09 PM
  To: concurrency-interest
  Subject: [concurrency-interest] Phaser question


  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/20110918/2d157f03/attachment.html>


More information about the Concurrency-interest mailing list