1 下载vscode
2 在插件店铺中搜索java,把开头几个包含java的插件全都安装好
3 新建文件test.java 并且把后面这个文件复制进去
import java.util.concurrent.Executor;
public class test {
public static void main(String[] args) throws InterruptedException {
SubExecutor subExecutor=new SubExecutor();
subExecutor.execute(new TicketStation(200));
subExecutor.execute(new TicketStation(200));
}
static class TicketStation implements Runnable{
static int TicketsCount=0;
static int sellout=0;
public TicketStation(int count){
TicketsCount=count;
}
@Override
public void run(){
while (TicketsCount>sellout) {
try {
sellout++;
System.out.println("ticket sell out:"+sellout);
Thread.sleep(50);
} catch (InterruptedException ex) {
}
}
}
}
static class SubExecutor implements Executor{
@Override
public void execute(Runnable r)
{
new Thread(r).start();
}
}
}
这样一个开发环境就全都配置好了
结果:
标签:集成,java,sellout,配置,static,TicketStation,new,public From: https://blog.csdn.net/geniusChinaHN/article/details/145134052