// waiting/pausing
static class Waits {
// vars
private static long waiter, timerStart;
private static double implicitWaitTime, restoreImplicitWaitTime;
private long _waiter;
private double _implicitWaitTime, _restoreImplicitWaitTime;
// timer
static void startTimer(){
timerStart = System.currentTimeMillis();
}
@SuppressWarnings("unused")
static String getTimerElapsedTime(){
long millis = System.currentTimeMillis() - timerStart;
long second = (millis / 1000) % 60;
long minute = (millis / (1000 * 60)) % 60;
long hour = (millis / (1000 * 60 * 60)) % 24;
return String.format("%02d:%02d", minute, second);
}
From the looks of it, this is not thread-safe correct? I need it to be thread-safe and I am not sure how to go about this. What else is there besides AtomicInteger
? I need each thread to be able to have its own timer.
EDIT: just found that AtomicInteger can't even be used for long
values