?????????????????????????????????????????????????????Java????δ?????????????????????????????????????Java?е???ó????????????????????????????δ???????????δ????????????????????????
?????.Java?й?????ó??????????????
??????.Java????δ??????
??????.Java????δ???????
?????.Java?й?????ó??????????????
??????Java?У??????ó??????????JVM???????е?????JVM?????????????????????java.exe????javaw.exe??windows???????????????????????Java???????????????????????????????????????????????????????????????????????????????????????????????????????????????????JVM????????????JVM???????????????????????????????????????????????????
????????Java?????????????????????????UI??????????????????????????н??У??????????????????UI????????????UI???????????????????????????
??????.Java????δ??????
??????java??????????????????????????????1?????Thread??2?????Runnable????
????1.???Thread??
???????Thread????????????дrun????????run?????ж????????е?????
????class MyThread extends Thread{
????private static int num = 0;
????public MyThread(){
????num++;
????}
????@Override
????public void run() {
????System.out.println("???????????"+num+"?????");
????}
????}
???????????????????????????????????????????????start()??????????????????????run()???????????run?????????????????е????????????run????????????????????????run????????????????????????κ????????????????????μ????????ж????????
public class Test {
public static void main(String[] args) {
MyThread thread = new MyThread();
thread.start();
}
}
class MyThread extends Thread{
private static int num = 0;
public MyThread(){
num++;
}
@Override
public void run() {
System.out.println("???????????"+num+"?????");
}
}
??????????????У????????start()??????????????μ?????????????start()???????ú?run()???????????????????????????
public class Test {
public static void main(String[] args) {
System.out.println("?????ID:"+Thread.currentThread().getId());
MyThread thread1 = new MyThread("thread1");
thread1.start();
MyThread thread2 = new MyThread("thread2");
thread2.run();
}
}
class MyThread extends Thread{
private String name;
public MyThread(String name){
this.name = name;
}
@Override
public void run() {
System.out.println("name:"+name+" ?????ID:"+Thread.currentThread().getId());
}
}
???????н????