Java Thread - 2

 

 

 

package com;

public   class  Test implements Runnable  {

    
public static void main(String[] args) {

    Test test 
= new Test();
    Thread thread 
= new Thread(test);
    thread.start();
    System.
out.println(System.currentTimeMillis());
//    try {
//        Thread.sleep(5000);
//    } catch (InterruptedException e) {
//        
//        e.printStackTrace();
//    }
    
//for (;;) 
    {
        System.
out.println(System.currentTimeMillis());
        System.
out.println(Thread.currentThread().getName() + " HaHa");
    }


    }


    
public void run() {
    
try {
        Thread.sleep(
5000);
    }
 catch (InterruptedException e) {
        
        e.printStackTrace();
    }

    
//for (;;) 
    {
        System.
out.println(Thread.currentThread().getName() + " ByeBye");
    }

    }


}

1211852076125
1211852076125
main HaHa
Thread-0 ByeBye

 

 

package com;

public   class  Test implements Runnable  {

    
public static void main(String[] args) {

    Test test 
= new Test();
    Thread thread 
= new Thread(test);
    thread.start();
    System.
out.println(System.currentTimeMillis());
    
try {
        Thread.sleep(
5000);
    }
 catch (InterruptedException e) {
        
        e.printStackTrace();
    }

    
//for (;;) 
    {
        System.
out.println(System.currentTimeMillis());
        System.
out.println(Thread.currentThread().getName() + " HaHa");
    }


    }


    
public void run() {
//    try {
//        Thread.sleep(5000);
//    } catch (InterruptedException e) {
//        
//        e.printStackTrace();
//    }
    
//for (;;) 
    {
        System.
out.println(Thread.currentThread().getName() + " ByeBye");
    }

    }


}

1211852205906
Thread-0 ByeBye
1211852210906
main HaHa

 

package com;

public   class  Test implements Runnable  {

    
public static void main(String[] args) {

    Test test 
= new Test();
    Thread thread 
= new Thread(test);
    thread.start();
    System.
out.println(System.currentTimeMillis());
    
try {
        Thread.sleep(
5000);
    }
 catch (InterruptedException e) {
        
        e.printStackTrace();
    }

    
//for (;;) 
    {
        System.
out.println(System.currentTimeMillis());
        System.
out.println(Thread.currentThread().getName() + " HaHa");
    }


    }


    
public void run() {
    
try {
        Thread.sleep(
5000);
    }
 catch (InterruptedException e) {
        
        e.printStackTrace();
    }

    
//for (;;) 
    {
        System.
out.println(Thread.currentThread().getName() + " ByeBye");
    }

    }


}

1211852246312
1211852251312
main HaHa
Thread-0 ByeBye

 

你可能感兴趣的:(Java Thread - 2)