org.cybergarage.util

## Class ThreadCore

- java.lang.Object
- - org.cybergarage.util.ThreadCore

- All Implemented Interfaces:
    Runnable
  Direct Known Subclasses:
    Advertiser, Disposer, RenewSubscriber

      public class ThreadCore
      extends Object
      implements Runnable

  Base class for managing thread lifecycle and execution. This class implements Runnable and provides methods to start, stop, restart, and manage thread execution in a safe manner using thread interruption.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ThreadCore()` Creates a new ThreadCore instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Thread` | `getThreadObject()` Gets the internal Thread object.
    `boolean` | `isRunnable()` Checks if the current thread is the same as this ThreadCore's thread.
    `void` | `restart()` Restarts the thread by stopping it first and then starting it again.
    `void` | `run()` The main execution method of the thread.
    `void` | `setThreadObject(Thread obj)` Sets the internal Thread object.
    `void` | `start()` Starts the thread if it's not already running.
    `void` | `stop()` Stops the thread safely using interruption.

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

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

- - ### Constructor Detail

    - #### ThreadCore

          public ThreadCore()

      Creates a new ThreadCore instance.

  - ### Method Detail

    - #### getThreadObject

          public Thread getThreadObject()

      Gets the internal Thread object.
      Returns:
        the Thread object, or null if not set

    - #### isRunnable

          public boolean isRunnable()

      Checks if the current thread is the same as this ThreadCore's thread.
      Returns:
        true if the current thread is running this ThreadCore, false otherwise

    - #### restart

          public void restart()

      Restarts the thread by stopping it first and then starting it again.

    - #### run

          public void run()

      The main execution method of the thread. This method should be overridden by subclasses to implement specific functionality.
      Specified by:
        `run` in interface `Runnable`

    - #### setThreadObject

          public void setThreadObject(Thread obj)

      Sets the internal Thread object.
      Parameters:
        `obj` - the Thread object to set

    - #### start

          public void start()

      Starts the thread if it's not already running. Creates a new Thread object if one doesn't exist.

    - #### stop

          public void stop()

      Stops the thread safely using interruption. This method interrupts the thread and clears the thread object reference.