@ThreadSafe public class MainThread extends Thread
Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
MainThread(int ticksPerSecond)
Creates the MainThread runner from the amount of heartbeats the server should take per second the server runs
|
Modifier and Type | Method and Description |
---|---|
void |
doRun() |
double |
getAverageTickLength()
Used to get the length of the average tick for the past 40 ticks
|
int |
getNotLostTicksElapsed()
Gets the ticks that were not lost in the time elapsed
|
int |
getTicksElapsed()
Gets the elapsed ticks
|
Thread.UncaughtExceptionHandler |
getUncaughtExceptionHandler() |
void |
interrupt() |
boolean |
pauseTicking()
Interesting new feature (relative to other implementations) that would allow it to pause ticking
|
boolean |
pauseTicking(int ticks)
Instead of needing to be resumed, it will instead just skip this many ticks and resume
|
void |
resumeTicking()
Complement to MainThread#pauseTicking(), resumes the ticking of the server
|
void |
run() |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public MainThread(int ticksPerSecond)
ticksPerSecond
- the amount of heartbeats per secondpublic void doRun() throws InterruptedException
InterruptedException
public boolean pauseTicking()
public boolean pauseTicking(int ticks)
ticks
- the ticks to pause forpauseTicking()
public void resumeTicking()
public Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
getUncaughtExceptionHandler
in class Thread
public double getAverageTickLength()
Does not count ticks that have been skipped via MainThread#pauseTicking()
public int getTicksElapsed()
public int getNotLostTicksElapsed()
Copyright © 2016. All rights reserved.