navigate.controller.thread_pool.SelfLockThread
- class navigate.controller.thread_pool.SelfLockThread(group=None, target=None, name=None, args=(), kwargs={}, *, daemon=None)
Bases:
ThreadA custom thread class with self-locking capabilities.
This class extends the functionality of the Python threading.Thread class by providing the ability to lock and unlock the thread explicitly. It is useful in scenarios where thread synchronization and control are required.
Note
This class provides additional control over thread execution using the wait() and unlock() methods.
It allows checking whether the thread is currently locked using the isLocked() method.
- __init__(group=None, target=None, name=None, args=(), kwargs={}, *, daemon=None)
Initialize the SelfLockThread.
- Parameters:
group (ThreadGroup, optional) – The thread group, by default None
target (callable, optional) – The target function of the thread, by default None
name (str, optional) – The name of the thread, by default None
args (tuple, optional) – The arguments of the target function, by default ()
kwargs (dict, optional) – The keyword arguments of the target function, by default {}
daemon (bool, optional) – Whether the thread is daemon, by default None
Methods
__init__([group, target, name, args, ...])Initialize the SelfLockThread.
isLocked()Check if the thread is locked.
run()Run the thread.
unlock()Unlock the thread.
wait()Wait for the thread to finish.
Attributes
- isLocked()
Check if the thread is locked.
- Returns:
Whether the thread is locked.
- Return type:
bool
- run()
Run the thread.
- unlock()
Unlock the thread.
- wait()
Wait for the thread to finish.
- selfLock
The lock of the thread.
- Type:
threading.Lock