Interface ServerThreadLock
- All Superinterfaces:
AutoCloseable,Terminable
A tool to synchronize code with the main server thread.
It is highly recommended to use this interface with try-with-resource blocks.
- See Also:
-
Field Summary
Fields inherited from interface dev.demeng.pluginbase.terminable.Terminable
EMPTY -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the lock, and allows the main thread to continuestatic ServerThreadLockobtain()Blocks the current thread until aServerThreadLockcan be obtained.Methods inherited from interface dev.demeng.pluginbase.terminable.Terminable
bindWith, closeAndReportException, closeSilently, isClosed
-
Method Details
-
obtain
Blocks the current thread until aServerThreadLockcan be obtained.Will attempt to return immediately if the calling thread is the main thread itself.
- Returns:
- a lock
-
close
void close()Closes the lock, and allows the main thread to continue- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceTerminable
-