- class lianxi5
- {
- public static void main(String[] args)
- {
- fu c = new fu();
- Thread t1=new Thread(c);
- Thread t2=new Thread(c);
- Thread t3=new Thread(c);
- t1.start();
- t2.start();
- t3.start();
- }
- }
- class fu implements Runnable
- {
- Object s = new Object();
- private int x=100;
- public void run()
- {
- synchronized(s)
- {
- for (int y=0;y<x ;y++ )
- {
-
- System.out.println("x"+y);
- }
- }
- }
- }
复制代码 |
|