简单的Thread实现

package source.com.thread;

public class ThreadDemo {

    /**
     * @param args
     */
    public static void main(String[] args) {
        
          Thread thread1=new Thread(){
              @Override
            public void run() {
                 while(true){
                     try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                     System.out.println("wqy"+Thread.currentThread().getName());
                 }
            }
          };
          thread1.start();
          
       
          new Thread(new Runnable() {
            
            @Override
            public void run() {
                while(true){
                     try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                     System.out.println("zzmmm"+Thread.currentThread().getName());
                 }
            }
        }).start();
          
     
    }
    
}

猜你喜欢

转载自blog.csdn.net/wwqqyy123456/article/details/82110058
今日推荐