???????????????
????//????????????????????????????????)
????new Thread(new RunnableTest()).start();
?????????????
1 class ThreadUseDemo
2 {
3     public static void main(String[] args)
4     {
5         //System.out.println("Hello World!");
6         //??????????????????
7         new Thread()
8         {
9             public void run()
10             {
11                 for(int i=0;i<100;i++)
12                 {
13                     System.out.println(Thread.currentThread().getName()+"?????1"+ i);
14                 }
15
16             }
17         }.start();
18         //???????????????
19         for(int i=0;i<100;i++)
20         {
21             System.out.println(Thread.currentThread().getName()+"?????"+ i);
22         }
23
24         //??????????????????
25         Runnable r =new Runnable()
26         {
27             public void run()
28             {
29                 for(int i=0;i<100;i++)
30                 {
31                     System.out.println(Thread.currentThread().getName()+".....???2++"+ i);
32                 }
33             }
34         }; //??????
35         new Thread(r).start();
36
37        //?????????????????????????????з??)
38        new ThreadTest().start();
39        //????????????????????????????????)
40        new Thread(new RunnableTest()).start();
41     }
42 }
43
44 class ThreadTest extends Thread
45 {
46     public void run()
47     {
48             for(int i=0;i<100;i++)
49             {
50                 System.out.println(Thread.currentThread().getName()+".....?????(extends)----"+ i);
51             }
52     }
53
54 }
55 class  RunnableTest implements Runnable
56 {
57     public void run()
58     {
59         for(int i=0;i<100;i++)
60         {
61             System.out.println(Thread.currentThread().getName()+".........?????(implements)----++"+ i);
62         }
63     }
64 }
????????????????????????????????????????????±??????????????
????1?????????
????????????????п?????λ???????????????????????????
????????????????????wait)??????????flag?????????????????????????
????Interrupt????????????????????????????????и?????λ????
????wait  ---
????sleep ----===????????---??????????????????->?????????????????????????????????false??????ж???????????
????2) ??????
????eg:   t1.setDaemon(true);//???t1???????????????????????????У?????CPU??????????????????????????????????????????????????)
????3) join()
????eg:  t1.start();t1.join();//t1??start??join?????CPU??????????CPU??????????wait??)??t1?????????????е??????????????t1????????????CPU
????4) ????飺???????????????????(?????ò???)
????5????????????1--10??????5???????????У?MIN_PRIORITY (1);MAX_PRIORITY (10); NORM_PRIORITY (5 )
???????壺
????????java???????????
????java.lang.Thread
????public static final int MAX_PRIORITY 10
????public static final int MIN_PRIORITY 1
????public static final int NORM_PRIORITY 5
????????
1 //????????
2 class MyThead implements Runnable
3 {
4     public void run()
5     {
6         for (int i = 1; i <= 10; i++)
7         {
8             System.out.println(Thread.activeCount() + "thread======>AAA");
9         }
10     }
11 }
12 //????????
13 class MyThreadRunnable extends Thread
14 {
15
16     public void run()
17     {
18         for (int i = 1; i <= 10; i++)
19         {
20             System.out.println(Thread.activeCount() + "thread======BBB");
21         }
22     }
23
24 }
25
26 public class TheadMain
27 {
28     public static void main(String[] args)
29     {
30         MyThead myThead = new MyThead();
31         Thread thread = new Thread(myThead);
32         MyThreadRunnable thread2 = new MyThreadRunnable();
33         thread.start();
34         thread.setPriority(Thread.MIN_PRIORITY);
35         thread2.start();
36         thread2.setPriority(Thread.MAX_PRIORITY);
37     }
38 }