//异步输出
//Q:当前时间的代码 3个线程 输出10s
function sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, time * 1000)
})
}
async function timeee() {
await console.log("线程1", mydate);
await console.log("线程3", mydate);
await console.log("线程2", mydate);
};
async function main() {
for (let i = 0; i < 10; i++) {
await sleep(1)
var mydate=new Date();
await console.log("线程1", mydate);
var mydate=new Date();
await console.log("线程3", mydate);
var mydate=new Date();
await console.log("线程2", mydate);
}
console.log('完成')
}
main() // 执行一下
console