标题: 线程问题--怎么看不到其他线程 [打印本页] 作者: 胥文 时间: 2013-2-21 17:09 标题: 线程问题--怎么看不到其他线程 public class ThreadTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
WindowTicket wt = new WindowTicket();
Thread t1 = new Thread(wt);
Thread t2 = new Thread(wt);
Thread t3 = new Thread(wt);
t1.start();
t2.start();
t3.start();
}
}
class WindowTicket implements Runnable
{
int ticket = 1000;
Object obj = new Object();
public void run()
{
synchronized(obj)
{
public static void main(String[] args) {
// TODO Auto-generated method stub
WindowTicket wt = new WindowTicket();
Thread t1 = new Thread(wt);
Thread t2 = new Thread(wt);
Thread t3 = new Thread(wt);
t1.start();
t2.start();
t3.start();
}
}
class WindowTicket implements Runnable
{
int ticket = 1000;
Object obj = new Object();
public void run()
{
synchronized(obj)
{