mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-02 16:38:14 +00:00
39 lines
703 B
JavaScript
39 lines
703 B
JavaScript
|
|
class Network {
|
|
constructor() { }
|
|
|
|
async sleep(ms) {
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
}
|
|
async task1() {
|
|
console.log("World.")
|
|
let val = true
|
|
while (val) {
|
|
await this.sleep(1000);
|
|
console.log("Task1 doing work.")
|
|
}
|
|
//throw Error("Ded World.")
|
|
}
|
|
|
|
async task2() {
|
|
console.log("Hello.")
|
|
let val = true
|
|
while (val) {
|
|
await this.sleep(1000);
|
|
console.log("Task2 doing work.")
|
|
}
|
|
//throw Error("Ded Hello.")
|
|
}
|
|
}
|
|
|
|
const network = new Network()
|
|
|
|
async function main() {
|
|
network.task1()
|
|
network.task2()
|
|
}
|
|
|
|
main()
|
|
|
|
|