Java ???thread (???)???
???????????? ???????[ 2014/2/19 9:20:48 ] ??????????? Java ????
??????Java?? thread ?????????.
?????????????? ?????????????????: ????????.
????????????????:
?????. ???????(Program)
??????ν???? ??1???????????????. ????漲???????????????????????????????????? ????????????.
????1.1 ???????????л???
??????ν??????????????? ?????????????????? ?????????1?????????.
?????????DOS????1?????????????????л???.
?????????????????????:
????1. ?????????: ?κ???? ????????1????????? ?????????????????????.
????2. ????????: ?????????1?????? ???????????????е?? ????????1???o? ???????????.
???????????????1??????????????? ?????????1??????.
????3.???????????: ????л???????????????? ??????1?????? ???????????????.
????1.2 ??????????л???
??????ν??????????л???????? ????????????????? ?????????ж?????????.
?????????unix?? linux?????????????????л???.
????????????????????:
????1. ?????: ???cpu??????????????л???У? ????cpu??г???A??????? ???л????г???B??????.
??????????????κ??? ???????????1??????A?????B????е????.
????2. ???????: ??????????????? ???????????乲??????? ???????.
????3. ??????????: ????????? ?????????????. ??????????? ?????????????????????????????.
??????. ???????(process)
?????????????????????????????л?????????.
????1?????????????????????е?1?????
???????????????????л????У? ?1?????????????????????????????????.
?????????????: ??????????????????????gvim ????????? ????????????????.
??????????ps -ef | grep gvim ?????????????????????gvim?????? ????????????id??????.
?????????? gvim????????????????????????????????.
???????????????л?????. ???y???????????????????????????????? ???????????????.
????????????????????????? ????????????????????????ε????. 1?????????????Σ? ????Σ? ?????????? ????????????????????? ???????????????.
??????. ???????(thread).
????????? ????????1????????????? ?????????????????????.
????????? ?????1??????????·??.
????????java?????????????main???????????У? main?????????????. ???????·????java??????????.
????????:
???????????????????????? 1?????????????1?????.
??????java??????????? ???1?????????????? ?????????1???????????????? cpu??????Щ?????м???л???У? ????????????е????.
??????. 1???????java??????????.
????????????:
package Thread_kng;
class S_thrd_1{
public void f(){
while (true){
System.out.printf("Thread main is runing!
");
}
//System.out.printf("f() is done!
"); //compilation fail
}
}
public class S_thread_expl{
public static void g(){
S_thrd_1 s = new S_thrd_1();
s.f();
System.out.printf("g() is done!
");
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11