-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSleep.java
More file actions
27 lines (24 loc) · 731 Bytes
/
Sleep.java
File metadata and controls
27 lines (24 loc) · 731 Bytes
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
import jdk.nashorn.api.scripting.AbstractJSObject;
public class Sleep extends AbstractJSObject {
@Override
public Object call(Object thiz, Object... args) {
if (args.length < 1)
return null;
Object time = args[0];
try {
if (time instanceof Double)
Thread.sleep(((Double) time).longValue());
else if (time instanceof Long)
Thread.sleep((Long)time);
else if (time instanceof Integer)
Thread.sleep((Integer)time);
} catch(InterruptedException e) {
e.printStackTrace();
}
return null;
}
@Override
public boolean isFunction() {
return true;
}
}