Class MainThreadRunner

java.lang.Object
com.jme3.app.state.BaseAppState
org.ngengine.runner.MainThreadRunner
All Implemented Interfaces:
AppState, Runner

public class MainThreadRunner extends BaseAppState implements Runner
Run in the jme3 main thread. The same as Jme3's Application.enqueue(Runnable) but the
  • Constructor Details

    • MainThreadRunner

      public MainThreadRunner(Application app)
  • Method Details

    • of

      public static MainThreadRunner of(Application app)
    • run

      public void run(Runnable task)
      Description copied from interface: Runner
      Run a task in the runner's thread, asap.
      Specified by:
      run in interface Runner
      Parameters:
      task -
    • enqueue

      public void enqueue(Runnable task)
      Description copied from interface: Runner
      Enqueue a task to be run in the runner's thread. This is the same as Runner.run(Runnable) but the task will be enqueued even if the call happens in the runner's thread.

      Generally, this is useful only for special use cases, like ensuring the thread doesn't get overloaded with too many tasks all at once. Otherwise just use Runner.run(Runnable).

      Specified by:
      enqueue in interface Runner
      Parameters:
      task -
    • initialize

      protected void initialize(Application app)
      Description copied from class: BaseAppState
      Called during initialization once the app state is attached and before onEnable() is called.
      Specified by:
      initialize in class BaseAppState
      Parameters:
      app - the application
    • cleanup

      protected void cleanup(Application app)
      Description copied from class: BaseAppState
      Called after the app state is detached or during application shutdown if the state is still attached. onDisable() is called before this cleanup() method if the state is enabled at the time of cleanup.
      Specified by:
      cleanup in class BaseAppState
      Parameters:
      app - the application
    • onEnable

      protected void onEnable()
      Description copied from class: BaseAppState
      Called when the state is fully enabled, ie: is attached and isEnabled() is true or when the setEnabled() status changes after the state is attached.
      Specified by:
      onEnable in class BaseAppState
    • onDisable

      protected void onDisable()
      Description copied from class: BaseAppState
      Called when the state was previously enabled but is now disabled either because setEnabled(false) was called or the state is being cleaned up.
      Specified by:
      onDisable in class BaseAppState