/*
13. 线程创建方法一:子类
14. */
15. Thread thread1 = new Thread(){
16. @Override
17. public void run()
18. {
19. //code
20. System.out.println(Thread.currentThread().getName()+" run...");
21. }
22. };
23. thread1.start();
24.
25. /*
26. 线程创建方法二:Runnable(更能体现面对对象思想)
27. */
28. Thread thread2 = new Thread(new Runnable(){
29. @Override
30. public void run()
31. {
32. //code
33. System.out.println(Thread.currentThread().getName()+" run...");
34. }
35. });
36. thread2.start();
|