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

java nioÔÚ¶àÏ̻߳·¾³ÏµĶñÃÎÖ®ÖÕ½á

ÓÐÈË˵java nioÔÚ¶àÏ̻߳·¾³Ï±à³Ì¼òÖ±¾ÍÊǸö¶ñÃÎ,ÆäʵÄãÈç¹ûÄܰÑÎÕסjava nio APIµÄÒªÁì,Äã¾Í¿ÉÒÔ½«Ö®¼ÝÔ¦.
0. Ò»¸ö channal ¶ÔÓ¦Ò»¸öSelectionKey in the same selector.
e.g:
SelectionKey sk=sc.register(selector, SelectionKey.OP_READ, handler);
sk==sc.register(selector, SelectionKey.OP_WRITE, handler) true?
selector.select() ÿ´Î·µ»ØµÄ¶ÔͬһchannalµÄskÊÇ·ñÏàͬ?
1.channel.register(...) may block if invoked concurrently with another registration[another.register(...)] or selection operation[selector.select(...)] involving *****the same selector*****.
Õâ¸öÊÇregister·½·¨jdk srcÉϵÄÔ­ÎÄ,
e.g:
Èç¹ûÒ»¸öselection threadÒѾ­ÔÚselect·½·¨Éϵȴýing,ÄÇôÕâ¸öʱºòÈç¹ûÓÐÁíÒ»ÌõÏ̵߳÷ÓÃchannal.register·½·¨µÄ»°,ÄÇôËü½«±»blocking.
2.selectionKey.cancel() : The key will be removed from all of the selector's key sets during *****the next selection operation[selector.select(...)]*****.
may block briefly if invoked concurrently with a cancellation[cancel()] or selection operation[select(...)] involving ***the same selector***.
Õâ¸öÒ²ÊÇcancel·½·¨jdk srcÉϵÄÔ­ÎÄ,
e.g:
ÄãÏȽ«Ò»¸öselectionKey.cancel(),È»ºóËæ¼´ÔÙchannel.register to the same selector,
ÔÚcancelºÍregisterÖ®¼ä,Èç¹ûûÓÐÏß³Ì(°üÀ¨µ±Ç°Ïß³Ì)½øÐÐselect²Ù×÷µÄ»°,
ÄÇô throws java.nio.channels.CancelledKeyException.
ËùÒÔ cancel-->select-->re-register. 
3.if don't remove the current selectedKey from selector.selectedKeys()[Set] ½«µ¼Ö selector.select(...) not block [may be cpu 100%,specially when client cut the current channel(connection)].
e.g:
Iterator<SelectionKey> it=selector.selectedKeys().iterator();
...for/while it.hasNext()...
it.remove();<------*****must do it. or Keys' Set.clear() finally;
if remove the current selectedKey from selector.selectedKeys()[Set] but don't sk.interestOps(sk.interestOps()& (~sk.readyOps()));½«µ¼Ö selector.select(...) not block [select() not block several times, or excepted exception]
4.op_write should not be registered to the selector. &nbs


Ïà¹ØÎĵµ£º

DWRÖÐJava·½·¨µÄ²ÎÊý¼°·µ»ØÖµ

DWRʹÓÃÆª
1¡¢µ÷ÓÃûÓзµ»ØÖµºÍ²ÎÊýµÄJava·½·¨
1.1¡¢dwr.xmlµÄÅäÖÃ
Xml´úÂë
<dwr>  
  <allow>  
    <create creator="new" javascript="testClass" >  
      <param name="class" value= ......

Java]JAVA»ñÈ¡Ïà¶Ô·¾¶ÎÊÌâµÄ½â¾ö

(ת£ºhttp://blog.csdn.net/alex197963/archive/2008/03/26/2219994.aspx)
1.»ù±¾¸ÅÄîµÄÀí½â
¡¡¡¡¾ø¶Ô·¾¶:¾ø¶Ô·¾¶¾ÍÊÇÄãµÄÖ÷Ò³ÉϵÄÎļþ»òĿ¼ÔÚÓ²ÅÌÉÏÕæÕýµÄ·¾¶,(URLºÍÎïÀí·¾¶)ÀýÈç:
C:xyz est.txt ´ú±íÁËtest.txtÎļþµÄ¾ø¶Ô·¾¶.http://www.sun.com/index.htmÒ²´ú±íÁËÒ»¸ö
URL¾ø¶Ô·¾¶.
¡¡¡¡Ïà¶Ô·¾¶:Ïà¶ÔÓëij¸ö» ......

ÐÂÊÖÈëÃÅ:дJava³ÌÐòµÄÈýÊ®¸ö»ù±¾¹æÔò

¡¡¡¡(1) ÀàÃûÊ××ÖĸӦ¸Ã´óд¡£×ֶΡ¢·½·¨ÒÔ¼°¶ÔÏó(¾ä±ú)µÄÊ××ÖĸӦСд¡£¶ÔÓÚËùÓбêʶ·û£¬ÆäÖаüº¬µÄËùÓе¥´Ê¶¼Ó¦½ô¿¿ÔÚÒ»Æð£¬¶øÇÒ´óдÖм䵥´ÊµÄÊ××Öĸ¡£ÀýÈ磺
¡¡¡¡ThisIsAClassName
¡¡¡¡thisIsMethodOrFieldName
¡¡¡¡ÈôÔÚ¶¨ÒåÖгöÏÖÁ˳£Êý³õʼ»¯×Ö·û£¬Ôò´óдstatic final»ù±¾ÀàÐͱêʶ·ûÖеÄËùÓÐ×Öĸ¡£ÕâÑù±ã¿É±êÖ¾³öË ......

ÉúƽµÚÒ»¶Î¹æ·¶Java´úÂë

ÏÂÃæÕâ¶Î´úÂëÊǾ­¹ý´úÂë·ÖÎö¹¤¾ßRational Software Analyser ·ÖÎö¹ýµÄ£¬¸Ã¹¤¾ß¹ØÓÚJavaµÄ¹æÔòĿǰÊÇ541Ìõ£¬ÊµÊô¿Á¿Ì¡£Ð´¶Î¹æ·¶µãµÄJava´úÂëÈÝÒ×ô£¡
/**
 *
 * @author zhp
 *
 * @version 1.0
 */
package com.rsar;
import java.util.Date;
/**
 *
 * @author zhp
  ......

¸ßÖÊÁ¿JAVA´úÂë±àд¹æ·¶

1. Java ÃüÃûÔ¼¶¨
¡¡¡¡³ýÁËÒÔϼ¸¸öÌØÀýÖ®Í⣬ÃüÃûʱӦʼÖÕ²ÉÓÃÍêÕûµÄÓ¢ÎÄÃèÊö·û¡£´ËÍ⣬һ°ãÓ¦²ÉÓÃСд×Öĸ£¬µ«ÀàÃû¡¢½Ó¿ÚÃûÒÔ¼°Èκηdzõʼµ¥´ÊµÄµÚÒ»¸ö×ÖĸҪ´óд¡£
1.1 Ò»°ã¸ÅÄî
¡¡¡¡* ¾¡Á¿Ê¹ÓÃÍêÕûµÄÓ¢ÎÄÃèÊö·û
¡¡¡¡* ²ÉÓÃÊÊÓÃÓÚÏà¹ØÁìÓòµÄÊõÓï
¡¡¡¡* ²ÉÓôóСд»ìºÏʹÃû×ֿɶÁ
¡¡¡¡* ¾¡Á¿ÉÙÓÃËõд£¬µ«Èç¹û ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ