Idea Plugin Dev - Thread (Write, Read and Lock Mechanism)

Card Puncher Data Processing

About

  • Data structures are covered by a single reader/writer lock.
  • Reading data is allowed from any thread (UI thread, …). Read operations performed from any other thread than UI need to be wrapped in a read action by using ApplicationManager.getApplication().runReadAction().
  • Writing data is only allowed from the UI thread, and write operations always need to be wrapped in a write action with ApplicationManager.getApplication().runWriteAction().

To pass control from a background thread to the event dispatch thread, instead of the standard SwingUtilities.invokeLater(), plugins should use ApplicationManager.getApplication().invokeLater(). The latter API allows specifying the modality state for the call, i.e. the stack of modal dialogs under which the call is allowed to execute.

Modality state:

  • ModalityState.NON_MODAL: the operation will be executed after all modal dialogs are closed.
  • ModalityState.stateForComponent(): the operation may be executed while the specified component (part of a dialog) is still visible.

Documentation / Reference







Share this page:
Follow us:
Task Runner