deeke-script-app 1.5.4 → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
|
|
2
|
+
function test() {
|
|
3
|
+
let script = "let a = 12;console.log(a);System.sleep(3000);console.log(a);System.sleep(3000);console.log(a);";
|
|
4
|
+
Engines.executeScriptStr(script);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// test();
|
|
8
|
+
|
|
9
|
+
// console.log(1);
|
|
10
|
+
// for(let i = 0;i<1000;i++){
|
|
11
|
+
// //
|
|
12
|
+
// }
|
|
13
|
+
// System.sleep(5000);
|
|
14
|
+
// console.log(2);
|
|
15
|
+
|
|
16
|
+
function test1() {
|
|
17
|
+
console.log("任务开始");
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
console.log("延时3秒执行完成");
|
|
20
|
+
}, 3000);
|
|
21
|
+
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
let i = 0;
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
let timer = setInterval(() => {
|
|
26
|
+
if (i >= 3) {
|
|
27
|
+
clearInterval(timer);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
console.log("每3秒执行一次:" + i++);
|
|
31
|
+
}, 3000);
|
|
32
|
+
|
|
33
|
+
console.log('任务结束');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// test1();
|
|
37
|
+
|
|
38
|
+
function test2() {
|
|
39
|
+
let script = "let a = 12;console.log(a);System.sleep(3000);setTimeout(()=>console.log(22), 3000);console.log(a);";
|
|
40
|
+
Engines.executeScriptStr(script);
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
console.log("延时3秒执行完成");
|
|
43
|
+
}, 3000);
|
|
44
|
+
}
|
|
45
|
+
// test2();
|
|
46
|
+
|
|
47
|
+
let timerIndex;
|
|
48
|
+
function test3() {
|
|
49
|
+
let obj = {
|
|
50
|
+
run: function () {
|
|
51
|
+
console.log('线程');
|
|
52
|
+
timerIndex = setInterval(() => {
|
|
53
|
+
for (let i = 0; i <= 5; i++) {
|
|
54
|
+
console.log('延时3秒执行完成');
|
|
55
|
+
}
|
|
56
|
+
}, 3000);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let thread = new java.lang.Thread(new java.lang.Runnable(obj));
|
|
61
|
+
|
|
62
|
+
thread.start();
|
|
63
|
+
thread.join();
|
|
64
|
+
console.log('主线程');
|
|
65
|
+
|
|
66
|
+
// setTimeout(() => {
|
|
67
|
+
// console.log("main-延时3秒执行完成", timerIndex);
|
|
68
|
+
// clearInterval(timerIndex);
|
|
69
|
+
// }, 12000);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
test3();
|