public class Multi {
public static void main(String args[]) {
Thread t1 = new MyThread("Steve");
Thread t2 = new MyThread("Jesse");
t1.start();
t2.start();
}
}
class MyThread extends Thread {
private String name;
public MyThread(String name) {
this.name = name;
}
@Override
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println(name + " " + i);
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
结果每次不一样:
Steve 0
Jesse 0
Steve 1
Jesse 1
Jesse 2
Steve 2
Jesse 3
Steve 3
Jesse 4
Jesse 5
Steve 4
Jesse 6
Steve 5
Jesse 7
Steve 6
Jesse 8
Steve 7
Jesse 9
Steve 8
Steve 9
分享到:
相关推荐
introduce in english
Java Programming for the Absolute Beginner.pdf
Java Programming for the Absolute Beginner
Fully updated to cover Java Platform, Standard Edition 7 (Java SE 7), Java: A Beginner's Guide, Fifth Edition starts with the basics, such as how to compile and run a Java program, and then discusses...
So many books out there can teach you those skills in Java, C++, or C#. Many of them even claim that they can teach you in 24 hours! Don’t laugh! They probably can do that, but all of them take one ...
Java A Beginner's Guide(6th) 英文无水印pdf 第6版 pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系...
Java2:A Beginner's Guide Second Edition 原版 pdf
Java For Absolute Beginner
sap mm docsfdsfdsfdsfdsfdsf
java 7 初学者教程
document for django 2.0 as a pdf document for begginner. including 7 examples with difficulty increasing more and more
Java A Beginner’s Guide(7th) 英文azw3 第7版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Java and Algorithmic Thinking for the Complete Beginner 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自...
一本适用于java初学者的英文版教材,很全面的介绍了Java的初阶内容。
Java A Beginner’s Guide(7th) 英文epub 第7版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
JAVA The Ultimate Beginner's Guide!,JAVA The Ultimate Beginner's Guide!
还记得编程冠军的代码吗? 本书简单介绍一下机器语言(自己还没看的,现在没那水平)感兴趣的可了解一下。第一次上传资源,就闹个0分吧。今后只要大家支持就行了。。
Developed by computer science instructors, books in the "for the absolute beginner" series teach the principles of programming through simple game creation. You will acquire the skills that you need ...
Java A Beginner's Guide(6th) 英文epub 第6版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Java A Beginner's Guide(6th) 英文mobi 第6版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除