// 测试线程
var obj = {
total: 0
}
var testThd = threads.start(function() {
setTimeout(() => {
obj.total = 10
console.log( '------------------', obj.total)
}, 3000);
})
// testThd.interrupt()
log( '------------------', obj.total)
// 打印结果:先打印 0, 三秒后在打印 10
// 测试线程
var obj = {
total: 0
}
var testThd = threads.start(function() {
setTimeout(() => {
obj.total = 10
}, 3000);
})
testThd.join() // 等待线程执行完成
// testThd.interrupt()
console.log( '------------------', obj.total)
// 打印结果: 三秒后在打印 10