Class AbstractAudioThread

java.lang.Object
java.lang.Thread
jmri.jmrit.audio.AbstractAudioThread
All Implemented Interfaces:
Runnable, AudioThread
Direct Known Subclasses:
AbstractAudioListener.AudioListenerMoveThread, AbstractAudioSource.AudioSourceFadeThread, AbstractAudioSource.AudioSourceMoveThread, AudioCommandThread

public abstract class AbstractAudioThread extends Thread implements AudioThread
Base implementation of all common thread code for use by threads in the various Audio classes.
This file is part of JMRI.

JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

  • Constructor Details

    • AbstractAudioThread

      Default constructor that gives this thread a unique name based on the value of the static counter
  • Method Details

    • cleanup

      protected void cleanup()
      Perform necessary cleanup routines before shutting down.
    • isThreadAlive

      public boolean isThreadAlive()
      Description copied from interface: AudioThread
      Checks if the thread is still alive (or in the process of shutting down)

      Once cleanup has finished, this should return False

      Specified by:
      isThreadAlive in interface AudioThread
      Returns:
      true, while thread is alive; false, when all cleanup has finished
    • die

      public void die()
      Description copied from interface: AudioThread
      Method used to tell the thread that it should shutdown
      Specified by:
      die in interface AudioThread
    • dying

      protected boolean dying()
      Checks if the thread is in the process of shutting down.
      Returns:
      true, if thread should die
    • snooze

      protected static void snooze(long ms)
      Sleep for the specified number of milliseconds.

      (Avoids cluttering the main code with the try-catch construct)

      Parameters:
      ms - number of milliseconds to sleep for