多线程1000米接力赛 您所在的位置:网站首页 接力赛跑规则10人怎么写 多线程1000米接力赛

多线程1000米接力赛

2024-07-09 20:44| 来源: 网络整理| 查看: 265

package homework; public class W1 implements Runnable{ private int count; private int x; public W1(int x) { super(); this.x = x; } public int getX() { return x; } public void setX(int x) { this.x = x; } @Override public void run() { try { Thread.sleep(2); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } synchronized (this) { for (int i = 1; i < 11; i++) { try { Thread.sleep(2); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (this.x==11|i>10) { return; } count+=10; System.out.println(x+"号选手跑了"+count+"米"); try { Thread.sleep(1); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (i==10&this.x


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有