-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimerThread.java
More file actions
43 lines (38 loc) · 1.07 KB
/
timerThread.java
File metadata and controls
43 lines (38 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.time.Clock;
import java.time.*;
class timerThread extends Thread implements java.io.Serializable
{
public static ZoneId zoneId = ZoneId.of("US/Arizona");
public static Clock myClock = Clock.system(zoneId);
long startTime;
long previousTime;
/*public static void main(String[] args){
int count = 0;
timerThread why = new timerThread();
why.setStart();
while(true){
if(why.every(1000)){
count++;
System.out.println(count);
}
}
}*/
//@Override
public timerThread(){
super();
setStart();
}
public void setStart(){
startTime = myClock.millis();
}
public void time() throws InterruptedException
{
previousTime = myClock.millis();
}
public boolean every(long ms){
return (myClock.millis()-startTime)%ms <= CircleOrbitMouse.refreshTime;
}
public boolean every(long ms, long creation){
return (myClock.millis()-creation)%ms <= CircleOrbitMouse.refreshTime;
}
}