JAVA ¶àÏß³Ì(¶ÁÊé±Ê¼Ç)
Ŀ¼
Éú³ÉÏ̵߳ÄÁ½ÖÖ·½·¨
Ï̵߳ÄÖжÏ
Ïß³Ì״̬
Ïß³ÌÊôÐÔ
ͬ²½
×èÈû¶ÓÁÐ
Ḭ̈߳²È«¼¯ºÏ
callable,Future
Ö´ÐÐÆ÷
ͬ²½Æ÷
Ï̺߳ÍSwing
Éú³ÉÏ̵߳ÄÁ½ÖÖ·½·¨
ʵÏÖRunnable,²¢×÷Ϊ²ÎÊý´«¸øThread
public class ThreadGenerieren {
public static void main(String[] args) {
RunnableExsample r = new RunnableExsample();
Thread t = new Thread(r);
t.start();
}
}
class RunnableExsample implements Runnable {
public void run() {
// code
}
}
ÖØдTreadµÄrun·½·¨
public class ThreadGenerieren {
public static void main(String[] args) {
ThreadExsample t = new ThreadExsample();
t.start();
}
}
class ThreadExsample extends Thread {
public void run() {
// code...
}
}
ÖжÏÏß³Ì
Ç¿ÖÆÖÕÖ¹Ï̵߳Ästop·½·¨ÒѾ±»ÆúÓ㬵«»¹¿ÉÒÔÓÃinterrupt·½·¨À´ÇëÇóÖÕÖ¹Ï̡߳£
Èç¹ûÒ»¸öÏ̱߳»×èÈûÁË£¬ÄǾÍÎÞ·¨¼ì²éÖжÏ״̬ÁË£¬Èç¹ûÔÚ×èÈûµÄÏß³ÌÉϵ÷ÓÃinterrupt£¬ÄÇô¾Í»á²úÉúInterruptedExceptionÒì³££¬×èÈûµ÷ÓÃ(Èçsleep»òwait)¾Í»á±»Õâ¸öÒì³£ËùÖÕÖ¹¡£
Èç¹ûÏ̵߳ÄÖжÏ״̬±»ÖÃλºóµ÷ÓÃsleep£¬ÄÇôsleepÅ׳öÒ»¸öInterruptedException,ͬʱÇå³ýÖжÏ״̬¡£
interrupted,islnterruptedÇø±ð¡£
Ïß³Ì״̬
4¸ö״̬:ÐÂÉú£¬¿ÉÔËÐУ¬±»×èÈû£¬ËÀÍö(new,runnable,blocked,dead)
Ïß³ÌÊôÐÔ
ÉèÖÃÏß³ÌÊôÐÔsetPriority(int newPriority),ĬÈÏÓÅÏȼ¶Îª5
µ÷ÓÃt.setDaemon(true)ÉèÖÃÒ»¸öÏß³ÌΪÊØ»¤Ị̈߳¬Î¨Ò»×÷ÓÃΪÆäËûÏÖ³ÉÌṩ·þÎñ£¬±ÈÈç¼ÆʱÆ÷Ị̈߳¬¶¨Ê±·¢³ö"ʱ¼äµÎ´ð"ÐźŸøÆäËûÏ̡߳£
Ïß³Ì×é¸ÅÄî TreadGroup g = new ThreadGroup(groupName); Thread t= new Thread(g, threadName);
Ï̵߳Ärun·½·¨²»Å׳öÒ쳣ҲûÓÐcatchÓï¾ä²¶×½Òì³££¬µ«ÊÇûÓмì²éµÄÒì³£¿ÉÒÔµ¼ÖÂÏß³ÌËÀÍö£¬Õâ¸öÒì³£×îºó±»´«µÝ¸øδ²¶×½Òì³£´¦ÀíÆ÷´¦Àí¡£´¦ÀíÆ÷ʵÏÖÁ˽ӿÚThread.UncaughtExceptionHandler¡£ setUncaughtExceptionHandler¿ÉÒÔΪÿ¸öḬ̈߳²×°´¦ÀíÆ÷£¬Èç¹ûûÓа²×°ÄÇĬÈÏ´¦ÀíÆ÷½«ÊÇnull£¬ÕâÑùµÄ»°´¦ÀíÆ÷¾ÍÊÇÏ̵߳ÄthreadGroup¶ÔÏó£¬ÒòΪthreadGroup¶ÔÏóʵÏÖÁË´¦ÀíÆ÷½Ó¿Ú£¬ËüµÄuncaughtException·½·¨ÈçϲÙ×÷:
Èç¹ûÏß³ÌÓи¸Ïß³Ì×飬Ôòµ÷Óø¸Ïß³Ì×éµÄuncaughtException·½·¨
·ñÔò£¬Èç¹ûthread.getDefualtExceptionHandler·½·¨·µ»Ø·Ç¿Õ´¦ÀíÆ÷£¬Ôòµ÷Óøô
Ïà¹ØÎĵµ£º
¶ÔÓÚÕâ¸öϵÁÐÀïµÄÎÊÌ⣬ÿ¸öѧJavaµÄÈ˶¼Ó¦¸Ã¸ã¶®¡£µ±È»£¬Èç¹ûÖ»ÊÇѧJavaÍæÍæ¾ÍÎÞËùνÁË¡£Èç¹ûÄãÈÏΪ×Ô¼ºÒѾ³¬Ô½³õѧÕßÁË£¬È´²»ºÜ¶®ÕâЩÎÊÌ⣬Ç뽫Äã×Ô¼ºÖعé³õѧÕßÐÐÁС£ÄÚÈݾùÀ´×ÔÓÚCSDNµÄ¾µäÀÏÌù¡£
ÎÊÌâÒ»£ºÎÒÉùÃ÷ÁËʲô£¡
String s = "Hello world!";
¡¡Ðí¶àÈ˶¼×ö¹ýÕâÑùµÄÊÂÇ飬µ«ÊÇ£¬ÎÒÃǵ½µ×ÉùÃ÷ÁËʲô£¿»Ø´ðͨ ......
Ò»£¬ÍøÂç±à³ÌÖÐÁ½¸öÖ÷ÒªµÄÎÊÌâ
Ò»¸öÊÇÈçºÎ׼ȷµÄ¶¨Î»ÍøÂçÉÏһ̨»ò¶ą̀Ö÷»ú£¬ÁíÒ»¸ö¾ÍÊÇÕÒµ½Ö÷»úºóÈçºÎ¿É¿¿¸ßЧµÄ½øÐÐÊý¾Ý´«Êä¡£
ÔÚTCP/IPÐÒéÖÐIP²ãÖ÷Òª¸ºÔðÍøÂçÖ÷»úµÄ¶¨Î»£¬Êý¾Ý´«ÊäµÄ·ÓÉ£¬ÓÉIPµØÖ·¿ÉÒÔΨһµØÈ·¶¨InternetÉϵÄһ̨Ö÷»ú¡£
¶øTCP²ãÔòÌṩÃæÏòÓ¦ÓõĿɿ¿µÄ»ò·Ç¿É¿¿µÄÊý¾Ý´«Êä»úÖÆ£¬ÕâÊÇÍøÂç±à³ÌµÄÖ÷Òª¶Ô ......
Java ±ê×¼ÈÕÖ¾¹¤¾ß Log4j µÄʹÓ㨸½Ô´´úÂ룩
Ô´´úÂëÏÂÔØ
Log4j ÊÇÊÂʵÉ쵀 Java ±ê×¼ÈÕÖ¾¹¤¾ß¡£»á²»»áÓà Log4j ÔÚÒ»¶¨³Ì¶ÈÉÏ¿ÉÒÔ˵ÊǺâÁ¿Ò»¸ö¿ª·¢ÈËÔ±ÊÇ·ñÊÇһλºÏ¸ñµÄ
Java ³ÌÐòÔ±µÄ±ê×¼¡£Èç¹ûÄãÊÇÒ»Ãû Java ³ÌÐòÔ±£¬Èç¹ûÄ㻹 ......
Java±à³ÌÄÇЩʶù
×÷Õߣº³ÂÔ¾·å¡¢ÀîÖбò¡¢¹ÈæçÓÂ
ͼÊéÏêϸÐÅÏ¢£º
ISBN£º9787302214052
¶¨¼Û£º39Ôª
Ó¡´Î£º1-1
×°Ö¡£ºÆ½×°
Ó¡Ë¢ÈÕÆÚ£º2009-12-30
ͼÊé¼ò½é£º
±¾ÊéÒÔͨË×Ò׶®µÄÓïÑԺʹúÂëʾÀý½éÉÜJavaÓïÑÔ±à³ÌµÄ¸÷ÖÖ֪ʶ£¬ÊÇÒ»±¾Ö¸µ¼³õѧÕß½øÐÐ×Ôѧ±à³Ì£¬²¢Í¨¹ýÏà¹ØÕ½ڸ½´øµÄÁ·Ï°ÈÚ»á¹áͨÏà¹Ø¼¼ÊõµÄÈëÃÅÊé¼®¡£ ......