blob: c53f1efacc87a90611c29ad0804f91458c3d6449 (
plain)
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
44
|
package ch.epfl.xblast;
/**
* Time unit constants.
*
* @author Pacien TRAN-GIRARD (261948)
* @author Timothée FLOURE (257420)
*/
public interface Time {
/**
* Number of seconds per minute.
*/
int S_PER_MIN = 60;
/**
* Number of milliseconds per second.
*/
int MS_PER_S = 1000;
/**
* Number of microseconds per second.
*/
int US_PER_S = 1000 * MS_PER_S;
/**
* Number of nanoseconds per second.
*/
int NS_PER_S = 1000 * US_PER_S;
/**
* Pauses the current thread for the given duration.
*
* @param ns the sleep duration (ns)
*/
static void sleep(long ns) {
try {
Thread.sleep((long) (ns / 1E6), (int) (ns % 1E6));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
|