js 实现红绿灯变换

class LightFn{
    async run(){
        while(true){
            console.log(‘this is green 3000‘);
            await this.sleep(3000);
            console.log(‘this is yellow 1000‘);
            await this.sleep(1000);
            console.log(‘this is red 2000‘);
            await this.sleep(2000);            
        }    
    }
    sleep(duration){
        return new Promise((resolve, reject)=>{
            setTimeout(resolve ,duration);
        })
    }
}

let a = new LightFn();
a.run();

 

js 实现红绿灯变换

上一篇:.net core自动发送后台请求写法


下一篇:目标检测网络CenterNet(四)