4
2
5
1
3
0011 0010 1010 1101 0001 0100 1011
2
创建线程有两种模式实现 Runnable 接口和继承 Thread
1. 实现 Runnable 接口( 13 - 6 )
class MyThread implements Runnable
{ public void run()
{
线程体; }
}
public class ThreadTest{
public static void main(String s[])
{ MyThread mt1=new MyThread();
MyThread mt2=new MyThread();
Thread t1=new Thread(mt1);
Thread t2=new Thread(mt2);
t1.start();
t2.start();
}
}
二.创建线程