Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8293839

Documentation memory consistency effects of runLater

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      It is not clear from the documentation of Platform#runLater if callers of must perform any synchronisation to have writes of the calling thread be visible in the JavaFX Application Thread. It is important to document either if callers can rely on runLater to do such synchronisation internally, or to document is users CAN NOT rely on runLater for this.

      I propose a change that documents that actions in a thread prior to submitting a runnable to Platform#runLater happen-before actions performed by the runnable in the JavaFX Application Thread.

      Currently runLater inherits the memory consistency effects of InvokeLaterDispatcher in most cases. InvokeLaterDispatcher uses BlockingDeque internally. This proposed change will document this in the same way as it is documented by BlockingDeque.

      Other implementations of runLater should have similar memory consistency effects. Otherwise much existing JavaFX code would probably be incorrect.

      Javadoc for BlockingDeque: https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/util/concurrent/BlockingDeque.html

      General information about memory consistency for multi-threaded Java programs: https://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html



            kcr Kevin Rushforth
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: