Package com.github.mafelp.utils
Class ShutdownProcess
java.lang.Object
java.lang.Thread
com.github.mafelp.utils.ShutdownProcess
- All Implemented Interfaces:
java.lang.Runnable
public class ShutdownProcess
extends java.lang.Thread
The class that handles the shutdown of the bot and saves its current state.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.logging.log4j.Logger
logger
The logging instance to log statements to the console and the log file.private boolean
useLogger
If the normal logging instance should be used to print statements to STDOUT.Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
Constructors Constructor Description ShutdownProcess()
The default constructor which sets the use logger to no.ShutdownProcess(boolean useLogger)
The constructor to specify manually, if a logger should be used (preferred). -
Method Summary
Modifier and Type Method Description void
run()
The method that handles the actual execution of the shutdown routine.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger loggerThe logging instance to log statements to the console and the log file. -
useLogger
private final boolean useLoggerIf the normal logging instance should be used to print statements to STDOUT. This is, because the logger will be shout down before this method could finish, so to indicate to the user that the program is doing something, normal print statements will be used.
-
-
Constructor Details
-
ShutdownProcess
public ShutdownProcess()The default constructor which sets the use logger to no. -
ShutdownProcess
public ShutdownProcess(boolean useLogger)The constructor to specify manually, if a logger should be used (preferred).- Parameters:
useLogger
- If the logger or print statements should be used.
-
-
Method Details
-
run
public void run()The method that handles the actual execution of the shutdown routine.- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-