Java第十次作业--多线程
Java第十次作业--多线程 (一)学习总结 1 . 用思维导图对java多线程的学习内容进行总结。 2.阅读程序,采用实现Runnable接口的方式用多线程实现这个小游戏 package test; class Tortoise implements Runnable { private int totalStep; private int tortoiseStep = 0; public Tortoise(int totalStep) { this.totalStep = totalStep; } public void run() { running(); } private synchronized void running() { System.out.println("龟兔赛跑开始了..."); while (tortoiseStep < totalStep) { tortoiseStep++; System.out.println("乌龟跑了" + tortoiseStep + "步..."); } } } class Hare implements Runnable { private int totalStep; private int hareStep = 0; public Hare(int totalStep) { this.totalStep =