-
Notifications
You must be signed in to change notification settings - Fork 1
/
interruption_timer.txt
24 lines (23 loc) · 1.08 KB
/
interruption_timer.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**How long the program has been running for while not paused. */
private static long runningTime = 0;
/**The start time.*/
private static long startTime = 0;
/**The system time at which the program is paused.*/
private static long pausedTime = 0;
/**The length of time at which the program is paused.*/
private static long stoppedTime = 0;
/**An array holding the intevals of the breaks.*/
private static int [] taskLengthTime = {2000, 5000}; //time is in milliseconds
public void Interuption(){
startTime = System.currentTimeMillis();
for (int i = 0; i < taskLengthTime.length; i++) {
while (runningTime < taskLengthTime[i]) {
runningTime = System.currentTimeMillis() - startTime - stoppedTime;
}
System.out.println("Break time @ " + taskLengthTime[i] + " milliseconds.");
pausedTime = System.currentTimeMillis();
//Time is currently paused
//On button click, resume the program here.
stoppedTime = System.currentTimeMillis() - pausedTime;
}
}