进程和线程一样,可以多个。进程是静态的,一个进程里可以有多个线程。
<wbr></wbr>
起动线程有两个方法:一个是接口RUNABLE,一个是继承THERAD
<wbr></wbr>
public class testthread{
public static void main(){
Runner1 r = new Runner1();
Thread t = new Thread(r);
t.start;
}
class Runner1 implements Runnable{
public void run(){
..........
}
}
}
<wbr></wbr>
第二种
<wbr></wbr>
public class testthread{
public static void main(){
Runner1 r = new Runner1();
r.start;
}
class Runner1 extends Thread{
public void run(){
..........
}
}
}
如果在方法只只有一个线程要开,其实很好办
public void xxxx(){
new Thread(this).start();
}
publicvoid run() {
......
}