Package jmri.jmrit.logixng.util
Class LogixNG_Thread
java.lang.Object
jmri.jmrit.logixng.util.LogixNG_Thread
Utilities for handling JMRI's LogixNG threading conventions.
For background, see http://jmri.org/help/en/html/doc/Technical/Threads.shtml
This is the ThreadingUtil class for LogixNG.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic voidvoidChecks if the the current thread is the LogixNG thread.static LogixNG_ThreadcreateNewThread(int threadID, String name) static LogixNG_ThreadcreateNewThread(String name) static voiddeleteThread(LogixNG_Thread thread) static LogixNG_ThreadgetThread(int threadID) intstatic intgetThreadID(String name) booleanstatic Collection<LogixNG_Thread>booleanCheck if on the LogixNG-operation thread.booleanvoidRun some LogixNG-specific code before returning.runOnLogixNGDelayed(ThreadingUtil.ThreadAction ta, int delay) Run some LogixNG-specific code at some later point, at least a known time in the future.voidRun some LogixNG-specific code at some later point.voidSet the thread to "in use".voidsetThreadName(String name) static voidstatic booleanvalidateNewThreadName(String name)
-
Field Details
-
ERROR_HANDLING_LOGIXNG_THREAD
- See Also:
-
DEFAULT_LOGIXNG_THREAD
- See Also:
-
DEFAULT_LOGIXNG_DEBUG_THREAD
- See Also:
-
-
Method Details
-
createNewThread
-
createNewThread
-
validateNewThreadName
-
getThread
-
getThreadID
-
deleteThread
-
getThreads
-
getThread
-
getThreadId
-
getThreadName
-
setThreadName
-
getThreadInUse
-
setThreadInUse
Set the thread to "in use". If a thread is in use, it cannot be unset as not in use. -
runOnLogixNG
Run some LogixNG-specific code before returning.Typical uses:
ThreadingUtil.runOnLogixNG(() -> { logixNG.doSomething(value); });- Parameters:
ta- What to run, usually as a lambda expression
-
runOnLogixNGEventually
Run some LogixNG-specific code at some later point.Please note the operation may have happened before this returns. Or later. No long-term guarantees.
Typical uses:
ThreadingUtil.runOnLogixNGEventually(() -> { sensor.setState(value); });- Parameters:
ta- What to run, usually as a lambda expression
-
runOnLogixNGDelayed
Run some LogixNG-specific code at some later point, at least a known time in the future.There is no long-term guarantee about the accuracy of the interval.
Typical uses:
ThreadingUtil.runOnLogixNGDelayed(() -> { sensor.setState(value); }, 1000);- Parameters:
ta- What to run, usually as a lambda expressiondelay- interval in milliseconds- Returns:
- reference to timer object handling delay so you can cancel if desired; note that operation may have already taken place.
-
isQueueEmpty
-
isLogixNGThread
Check if on the LogixNG-operation thread.- Returns:
- true if on the LogixNG-operation thread
-
checkIsLogixNGThread
Checks if the the current thread is the LogixNG thread. The check is only done if debug is enabled. -
stopAllLogixNGThreads
-
assertLogixNGThreadNotRunning
-