gistfile1.txt interface IBase{ do(i:number):Promise ;}class BaseClass implements IBase{ async do(i:number):Promise { return new Promise((resolve,reject)={ setTimeout(()={ resolve(); },i); }); } } class Aclass extends BaseClass{ async run(i:
interface IBase{ do(i:number):Promise ; } class BaseClass implements IBase{ async do(i:number):Promise { return new Promise((resolve,reject)=>{ setTimeout(()=>{ resolve(); },i); }); } } class Aclass extends BaseClass{ async run(i:number,s:string):Promise{ let j = 0; while(j<10){ console.log(s); await this.do(i); j++; } } } async function main(){ let a = new Aclass(); let b = new Aclass(); a.run(2000,'aaaaa'); b.run(3500,'bbbbb'); } main(); 对应的输出(a每两秒输出一次,b每3.5秒输出一次,他们之间相互不影响各自的时间间隔,犹豫多线程一样。):