Skip to content
On this page

线程相关 - js版引擎独享

javascript
const core = require('cheese-js');

创建线程:public create(callback: Callback): Thread

用法示例:

javascript
const core = require('cheese-js'); //导入核心模块
const thread = new core.thread;
const base =  core.base;
let th =thread.create(() =>{
    while (true) {
        console.log("我是子线程")
        base.sleep(1000)
    }
})
console.log("线程id",th.getId())
base.sleep(1000)
//一秒后停止
th.exit()