java.lang.Object
org.cybergarage.util.ThreadCore
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
Advertiser, Disposer, RenewSubscriber
Field Summary
FieldsConstructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionGets the internal Thread object.booleanChecks if the current thread is the same as this ThreadCore's thread.voidrestart()Restarts the thread by stopping it first and then starting it again.voidrun()The main execution method of the thread.voidsetThreadObject(Thread obj) Sets the internal Thread object.voidstart()Starts the thread if it's not already running.voidstop()Stops the thread safely using interruption.
Field Details
mThreadObject
/////////////////////////////////////////////
Constructor Details
ThreadCore
public ThreadCore()Creates a new ThreadCore instance.
Method Details
setThreadObject
Sets the internal Thread object.- Parameters:
obj- the Thread object to set
getThreadObject
Gets the internal Thread object.- Returns:
- the Thread object, or null if not set
start
public void start()Starts the thread if it's not already running. Creates a new Thread object if one doesn't exist.run
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
stop
public void stop()Stops the thread safely using interruption. This method interrupts the thread and clears the thread object reference.restart
public void restart()Restarts the thread by stopping it first and then starting it again.