- class ThreadDemo{
- public static void main(String[] args) {
- TD1 td1=new TD1();
- TD2 td2=new TD2();
- td1.start();
- td2.start();
- int b=4/0;
- System.out.println("Hello World!");
- }
- }
- class TD1 extends Thread{
- public void run(){
- for (int i=1;i<15 ; i++) {
- System.out.println("i:td1*****"+i);
- }
- }
- }
- class TD2 extends Thread{
- public void run(){
- for (int i=1;i<15 ; i++) {
- System.out.println("i:td2----"+i);
- }
- }
- }
复制代码 |
|