Java多執行緒 匿名內部類實現多執行緒
阿新 • • 發佈:2018-12-26
class ThreadTest { public static void main(String[] args) { new Thread() { public void run() { for(int x=0; x<100; x++) { System.out.println(Thread.currentThread().getName()+"....."+x); } } }.start(); for(int x=0; x<100; x++) { System.out.println(Thread.currentThread().getName()+"....."+x); } Runnable r = new Runnable() { public void run() { for(int x=0; x<100; x++) { System.out.println(Thread.currentThread().getName()+"....."+x); } } }; new Thread(r).start(); //new Test1().start(); } }