Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÓÃJavaʵÏÖ·Ç×èÈûͨÐÅ

ÓÃServerSocketºÍSocketÀ´±àд·þÎñÆ÷³ÌÐòºÍ¿Í»§³ÌÐò£¬ÊÇJavaÍøÂç±à³ÌµÄ×î»ù±¾µÄ·½Ê½¡£ÕâЩ·þÎñÆ÷³ÌÐò»ò¿Í»§³ÌÐòÔÚÔËÐйý³ÌÖг£³£»á×èÈû¡£ÀýÈçµ±Ò»¸öÏß³ÌÖ´ÐÐServerSocketµÄaccept()·½·¨Ê±£¬¼ÙÈçûÓпͻ§Á¬½Ó£¬¸ÃÏ߳̾ͻáÒ»Ö±µÈµ½ÓÐÁË¿Í»§Á¬½Ó²Å´Óaccept()·½·¨·µ»Ø¡£ÔÙÀýÈçµ±Ïß³ÌÖ´ÐÐSocketµÄread()·½·¨Ê±£¬Èç¹ûÊäÈëÁ÷ÖÐûÓÐÊý¾Ý£¬¸ÃÏ߳̾ͻáÒ»Ö±µÈµ½¶ÁÈëÁË×ã¹»µÄÊý¾Ý²Å´Óread()·½·¨·µ»Ø¡£
¼ÙÈç·þÎñÆ÷³ÌÐòÐèҪͬʱÓë¶à¸ö¿Í»§Í¨ÐÅ£¬¾Í±ØÐë·ÖÅä¶à¸ö¹¤×÷Ị̈߳¬ÈÃËüÃÇ·Ö±ð¸ºÔðÓëÒ»¸ö¿Í»§Í¨ÐÅ£¬µ±È»Ã¿¸ö¹¤×÷Ï̶߳¼ÓпÉÄܾ­³£´¦ÓÚ³¤Ê±¼äµÄ×èÈû״̬¡£
´ÓJDK1.4°æ±¾¿ªÊ¼£¬ÒýÈëÁË·Ç×èÈûµÄͨÐÅ»úÖÆ¡£·þÎñÆ÷³ÌÐò½ÓÊÕ¿Í»§Á¬½Ó¡¢¿Í»§³ÌÐò½¨Á¢Óë·þÎñÆ÷µÄÁ¬½Ó£¬ÒÔ¼°·þÎñÆ÷³ÌÐòºÍ¿Í»§³ÌÐòÊÕ·¢Êý¾ÝµÄ²Ù×÷¶¼¿ÉÒÔ°´·Ç×èÈûµÄ·½Ê½½øÐС£·þÎñÆ÷³ÌÐòÖ»ÐèÒª´´½¨Ò»¸öỊ̈߳¬¾ÍÄÜÍê³ÉͬʱÓë¶à¸ö¿Í»§Í¨ÐŵÄÈÎÎñ¡£
·Ç×èÈûµÄͨÐÅ»úÖÆÖ÷ÒªÓÉjava.nio°ü£¨ÐÂI/O°ü£©ÖеÄÀàʵÏÖ£¬Ö÷ÒªµÄÀà°üÀ¨ServerSocketChannel¡¢SocketChannel¡¢Selector¡¢SelectionKeyºÍByteBufferµÈ¡£
Ò»¡¢Ïß³Ì×èÈû
ÔÚÉú»îÖУ¬×î³£¼ûµÄ×èÈûÏÖÏóÊǹ«Â·ÉÏÆû³µµÄ¶ÂÈû¡£Æû³µÔÚ¹«Â·ÉÏ¿ìËÙÔËÐУ¬Èç¹ûÇ°·½½»Í¨ÊÜ×裬¾ÍÖ»ºÃÍ£ÏÂÀ´µÈ´ý£¬µÈµ½¹«Â·Ë³³©£¬²ÅÄָܻ´ÔËÐС£
Ïß³ÌÔÚÔËÐÐÖÐÒ²»áÒòΪijЩԭÒò¶ø×èÈû¡£ËùÓд¦ÓÚ×èÈû״̬µÄÏ̵߳Ĺ²Í¬ÌØÕ÷ÊÇ£º·ÅÆúCPU£¬ÔÝÍ£ÔËÐУ¬Ö»Óеȵ½µ¼ÖÂ×èÈûµÄÔ­ÒòÏû³ý£¬²ÅÄָܻ´ÔËÐУ»»òÕß±»ÆäËûÏß³ÌÖжϣ¬¸ÃÏ̻߳áÍ˳ö×èÈû״̬£¬²¢ÇÒÅ׳öInterruptedException¡£
1£®Ïß³Ì×èÈûµÄÔ­Òò
µ¼ÖÂÏß³Ì×èÈûµÄÔ­ÒòÖ÷ÒªÓÐÒÔÏ·½Ã棺
Ïß³ÌÖ´ÐÐÁËThread.sleep(int n)·½·¨£¬Ï̷߳ÅÆúCPU£¬Ë¯ÃßnºÁÃ룬Ȼºó»Ö¸´ÔËÐС£
Ïß³ÌÒªÖ´ÐÐÒ»¶Îͬ²½´úÂ룬ÓÉÓÚÎÞ·¨»ñµÃÏà¹ØµÄͬ²½Ëø£¬Ö»ºÃ½øÈë×èÈû״̬£¬µÈµ½»ñµÃÁËͬ²½Ëø£¬²ÅÄָܻ´ÔËÐС£
Ïß³ÌÖ´ÐÐÁËÒ»¸ö¶ÔÏóµÄwait()·½·¨£¬½øÈë×èÈû״̬£¬Ö»Óеȵ½ÆäËûÏß³ÌÖ´ÐÐÁ˸öÔÏóµÄnotify()»ònotifyAll()·½·¨£¬²Å¿ÉÄܽ«Æ份ÐÑ¡£
Ïß³ÌÖ´ÐÐI/O²Ù×÷»ò½øÐÐÔ¶³ÌͨÐÅʱ£¬»áÒòΪµÈ´ýÏà¹ØµÄ×ÊÔ´¶ø½øÈë×èÈû״̬¡£ÀýÈçµ±Ïß³ÌÖ´ÐÐSystem.in.read()·½·¨Ê±£¬Èç¹ûÓû§Ã»ÓÐÏò¿ØÖÆ̨ÊäÈëÊý¾Ý£¬Ôò¸ÃÏ̻߳áÒ»Ö±µÈ¶Áµ½ÁËÓû§µÄÊäÈëÊý¾Ý²Å´Óread()·½·¨·µ»Ø¡£
½øÐÐÔ¶³ÌͨÐÅʱ£¬ÔÚ¿Í»§³ÌÐòÖУ¬Ïß³ÌÔÚÒÔÏÂÇé¿ö¿ÉÄܽøÈë×èÈû״̬£º
ÇëÇóÓë·þÎñÆ÷½¨Á¢Á¬½Óʱ£¬¼´µ±Ïß³ÌÖ´ÐÐSocketµÄ´ø²ÎÊýµÄ¹¹Ôì·½·¨£¬»òÖ´ÐÐSocketµÄconnect()·½·¨Ê±£¬»á½øÈë×èÈû״̬£¬Ö±µ½Á¬½Ó³É¹¦£¬´ËÏ̲߳ŴÓSocketµÄ¹¹Ôì·½·¨»òconnect()


Ïà¹ØÎĵµ£º

IBM FileNet Content Java API ¼ò½é

2008 Äê 6 ÔÂ 24 ÈÕ
Ô­ÎĵØÖ·£º http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0806wangys/
±¾ÎĽéÉÜ IBM FileNet P8 4.0 Platform ÌṩµÄ Content Java API¡£Ê×ÏÈ¶Ô FileNet P8 Content Engine ºÍ API ½øÐиÅÒª½éÉÜ, ²¢ËµÃ÷ÁËһЩ»ù±¾¸ÅÄËæºóÏêϸ½éÉÜÁË FileNet Content EngineÌṩµÄ»ùÓÚ EJB ......

java List ÅÅÐò Collections.sort() ¶Ô List ÅÅÐò

class User {
String name;
String age;

public User(String name,String age){
this.name=name;
this.age=age;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(St ......

Java theory and practice

1. Multiply-Thread
Locks offer two primary features: mutual exclusion and visibility. Mutual exclusion means only one thread at a time may hold a given lock, so only one thread at a time will be using the shared data. Visibility is to ensure that changes made to shared data prior to releasing a lo ......

java JDBC ResultSetÏê½â(javaÊý¾Ý¿â²Ù×÷)

ÕâƪÎÄÕ²¢Ã»Óиø³öÈçºÎʹÓÃResultSetµÄ¾ßÌåÀý×Ó£¬Ö»ÊÇ´ÓResultSetµÄ¹¦ÄÜÐÔÉϽøÐÐÁËÏêϸµÄ½²Êö¡£Ï£ÍûÕâƪÎÄÕ¶Դó¼ÒÀí½âResultSetÄܹ»ÓÐËù°ïÖú¡£ÏÂÃæ¾ÍÊÇÕâƪÎÄÕµľßÌåÄÚÈÝ¡£
½á¹û¼¯(ResultSet)ÊÇÊý¾ÝÖвéѯ½á¹û·µ»ØµÄÒ»ÖÖ¶ÔÏ󣬿ÉÒÔ˵½á¹û¼¯ÊÇÒ»¸ö´æ´¢²éѯ½á¹ûµÄ¶ÔÏ󣬵«Êǽá¹û¼¯²¢²»½ö½ö¾ßÓд洢µÄ¹¦ÄÜ£¬Ëûͬʱ»¹¾ßÓв ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ