Java?????--????????????????????????
???????????? ???????[ 2014/4/10 10:15:41 ] ????????Java ?????
??????????????д??????????????е????????oracle??????У??????????????????????????????????????????е???ν????????????????????
??????????????????????????????????????????У???д??????????????????????????????????????????????????????????????????????????System.currentTimeMillis???????????????????????????????????????????????????????????????
long tStart = System.currentTimeMillis????;
System.out.println??Thread.currentThread????.getName???? + "???"??;//?????????
for ??int ii = 0; ii < threadNum; ii++?? {//??threadNum?????
Runnable r = new Runnable????{
??Override
public void run????{
System.out.println??Thread.currentThread????.getName???? + "???"??;
//???Щ????... ...
System.out.println??Thread.currentThread????.getName???? + "????."??;
}
}
Thread t = new Thread??r??;
t.start????;
}
System.out.println??Thread.currentThread????.getName???? + "????."??;//??????????
long tEnd = System.currentTimeMillis????;
System.out.println??"??????:"+ ??tEnd - tStart?? + "millions"??;
long tStart = System.currentTimeMillis????;
System.out.println??Thread.currentThread????.getName???? + "???"??;//?????????
for ??int ii = 0; ii < threadNum; ii++?? {//??threadNum?????
Runnable r = new Runnable????{
??Override
public void run????{
System.out.println??Thread.currentThread????.getName???? + "???"??;
//???Щ????... ...
System.out.println??Thread.currentThread????.getName???? + "????."??;
}
}
Thread t = new Thread??r??;
t.start????;
}
System.out.println??Thread.currentThread????.getName???? + "????."??;//??????????
long tEnd = System.currentTimeMillis????;
System.out.println??"??????:"+ ??tEnd - tStart?? + "millions"??;
??????????????for???????????????????????????????????????????е?????????????е??????????????????????У??????????????????????????"????????????????????????"??????????????????????t.join????????????????????????У??????????????????????????????????
????????Google????????????????????????????????????????????????????????????????????????????...
????????????????????????ImportThread??????java.lang.Thread??????run???????????????List??????????в????????????????ж????List????????????????????????????????????????£?
public class ImportThread extends Thread {
private static List<Thread> runningThreads = new ArrayList<Thread>????;
public ImportThread???? {
}
??Override
public void run???? {
regist??this??;//?????????
System.out.println??Thread.currentThread????.getName???? + "???..."??;//?????????
//???Щ????... ...
unRegist??this??;//?????????????
System.out.println??Thread.currentThread????.getName???? + "????."??;//??????????
}
public void regist??Thread t??{
synchronized??runningThreads??{
runningThreads.add??t??;
}
}
public void unRegist??Thread t??{
synchronized??runningThreads??{
runningThreads.remove??t??;
}
}
public static boolean hasThreadRunning???? {
return ??runningThreads.size???? > 0??;//????ж?runningThreads???????????????????δ?????
}
}
public class ImportThread extends Thread {
private static List<Thread> runningThreads = new ArrayList<Thread>????;
public ImportThread???? {
}
??Override
public void run???? {
regist??this??;//?????????
System.out.println??Thread.currentThread????.getName???? + "???..."??;//?????????
//???Щ????... ...
unRegist??this??;//?????????????
System.out.println??Thread.currentThread????.getName???? + "????."??;//??????????
}
public void regist??Thread t??{
synchronized??runningThreads??{
runningThreads.add??t??;
}
}
public void unRegist??Thread t??{
synchronized??runningThreads??{
runningThreads.remove??t??;
}
}
public static boolean hasThreadRunning???? {
return ??runningThreads.size???? > 0??;//????ж?runningThreads???????????????????δ?????
}
}
??????
???·???
??????????????????
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