org.eclipse.viatra.dse.base

## Class ExplorerThread

- java.lang.Object
- - org.eclipse.viatra.dse.base.ExplorerThread

- All Implemented Interfaces:
    java.lang.Runnable

      public class ExplorerThread
      extends java.lang.Object
      implements java.lang.Runnable

  This class implements the `Runnable` interface, to able to run an exploration strategy in a separate thread. It is also responsible to initialize the exploration, start the exploration (call the `IStrategy.explore()` method), catch any exception during exploration and to shutdown the thread correctly.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExplorerThread(ThreadContext context)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `dispose()` Disposes of this strategy.
    `ThreadContext` | `getThreadContext()` Returns the associated `ThreadContext` that houses all the thread specific data about the exploration process, and is also the gateway to the `GlobalContext` which stores data relevant to the design space exploration process as a whole.
    `void` | `run()` Starts the design space exploration.
    `void` | `stopRunning()` Signals the `IStrategy` instance that execution should be stopped.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ExplorerThread

          public ExplorerThread(ThreadContext context)

  - ### Method Detail

    - #### stopRunning

          public void stopRunning()

      Signals the `IStrategy` instance that execution should be stopped. By contract, the strategy is to stop execution at the next stage of execution where stopping and exiting is appropriate.

    - #### run

          public void run()

      Starts the design space exploration. Returns only when the `IStrategy.explore()` method returns.
      Specified by:
        `run` in interface `java.lang.Runnable`

    - #### dispose

          public void dispose()

      Disposes of this strategy. Recursively calls dispose on the underlying `RuleEngine` and `ViatraQueryEngine`. Calling this is only required if the design space exploration was launched in thread, as the underlying engines get collected on the stop of the running `Thread`.

    - #### getThreadContext

          public ThreadContext getThreadContext()

      Returns the associated `ThreadContext` that houses all the thread specific data about the exploration process, and is also the gateway to the `GlobalContext` which stores data relevant to the design space exploration process as a whole.
      Returns:
        the relevant `ThreadContext`.