class A {
public static void main(String[] args) {
A a = new A();
new MT("-",a).start();
new MT("-------",a).start();
}}
class MT extends Thread {
Object o;
String str;
public MT(String str, Object o) {
this.str = str;
this.o = o;
}
public void run() {
while(true) {
synchronized(o) {
System.out.println(str);
o.notify();
}
}
}
}
public static void main(String[] args) {
A a = new A();
new MT("-",a).start();
new MT("-------",a).start();
}}
class MT extends Thread {
Object o;
String str;
public MT(String str, Object o) {
this.str = str;
this.o = o;
}
public void run() {
while(true) {
synchronized(o) {
System.out.println(str);
o.notify();
}
}
}
}
http://libo-lighting.51.net/javajia/article.php?id=169
http://www.ccw.com.cn/htm/center/prog/02_7_12_3.asp
这样的信息网上很多,可以通过google去搜索。