JAVA²¢·¢±à³Ì±Ê¼Ç£¨3£©
Publication and Escape ·¢²¼Ò»¸ö¶ÔÏóÒâζ×ÅÄܹ»´ÓËüÄܹ»´ÓËüµ±Ç°·¶Î§Ö®Íâ±»·ÃÎʵ½¡£±ÈÈ磬±£´æ¿ÉÒÔ±»ÆäËû´úÂëÕÒµ½µÄÕâ¸ö¶ÔÏóµÄÒ»¸öÒýÓ㬻òÕß½«Æä×÷Ϊһ¸ö·Ç˽Óз½·¨µÄ·µ»ØÖµ£¬»òÕß½«Æä×÷Ϊ²ÎÊý´«µÝ¸øÆäËüµÄÀà¡£ public static Set<Secret> knownSecrets;
public void initialize() {
knownSecrets = new HashSet<Secret>();
}
Õâ¸öknownSecrets¾Í±»·¢²¼ÁË£¬²¢ÇÒ£¬knownSecretsÀïÃæÌí¼ÓµÄËùÓÐsecretÒ²¶¼±»·¢²¼³öÈ¥ÁË¡£
class UnsafeStates {
private String[] states = new String[] {
"AK", "AL" ...
};
public String[] getStates() { return states; }
}
Õâ¸östates¾Í±»·¢²¼ÁË£¬¶øÇÒ´øÀ´µÄÎÊÌâÊÇÈκε÷ÓÃÕ߶¼Äܹ»ÐÞ¸ÄÀïÃæµÄÄÚÈÝ£¬ÕâÑù£¬ºÜ²»°²È«¡£
public class ThisEscape {
public ThisEscape(EventSource source) {
source.registerListener(
new EventListener() {
public void onEvent(Event e) {
doSomething(e);
}
});
}
}
¿´Ã÷°×Õâ¸öThisEscapeΪʲô±»·¢²¼ÁËô£¿ÒòΪËü·¢²¼ÁËEventListener£¬¶øÄÚ²¿Àà»á´øÓÐÒ»¸öÒþʽµÄ¶ÔÍⲿÀàµÄÒýÓá£
ÁíÍ⣬ÉÏÃæÕâ¸öÀàµÄÒ»¸öÑÏÖØÎÊÌâÊÇ£¬ÔÚ¹¹Ôì·½·¨ÖÐthisÒýÓÃescapeÁË¡£ÕâÒ²¾ÍÒâζ×ÅÕâ¸ö¶ÔÏóÔÚ±»·¢²¼µÄʱºò»¹´¦ÓÚÒ»¸ö²»ÍêÕûµÄ״̬¡£Ò»¸ö³£¼ûµÄÇéÐξÍÊÇÔÚÀàµÄ¹¹Ôì·½·¨ÖÐÆô¶¯Ò»¸öÏ̡߳£When an object creates a thread from its constructor, it almost always shares its this reference with the new thread, either explicitly (by passing it to the constructor) or implicitly (because the Thread or Runnable is an inner class of the owning object). µ±È»Õâ±¾ÉíûʲôÎÊÌ⣬µ«×îºÃ²»ÒªÔÚ¹¹Ôì·½·¨ÖоÍÆô¶¯Õâ¸öỊ̈߳¬¶øÊÇ°ÑThread.start()·Åµ½Ò»¸öµ¥¶ÀµÄinit·½·¨Öй©ÆäËü¶ÔÏóµ÷Óá£
Òª±ÜÃâ²»ÍêÈ«¹¹ÔìµÄÎÊÌ⣬¿ÉÒÔ²ÉÓÃÏÂÃæµÄ·½Ê½£º
public class SafeListener {
private final EventListener listener;
private SafeListener() {
listener = new EventListener() {
public void onEvent(Event e) {
doSomething(e);
}
};
}
public static SafeListener newInstance(EventSource source) {
SafeListener safe =
Ïà¹ØÎĵµ£º
JDK 6.0 ÒÔ¼°JDK 5.0 update 9 µÄ nioÖ§³Öepoll £¨½öÏÞ Linux
ϵͳ
£©£¬¶Ô²¢·¢idle connection»áÓдó·ù¶ÈµÄÐÔÄÜÌáÉý£¬Õâ¾ÍÊǺܶàÍøÂç·þÎñÆ÷Ó¦ÓóÌÐòÐèÒªµÄ¡£
ÆôÓõķ½·¨ÈçÏ£º
-Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.EPollSelectorProvider
ÀýÈçÔÚ Linux ÏÂÔËÐÐµÄ Tomcat ʹÓà NIO Connector £¬ÄÇôÆô ......
¾ÝÎĵµËù˵£¬ÀàÔöÇ¿Æ÷±ÈÓôúÀíµÄ·½Ê½ËÙ¶ÈÉÏÓÐÓÅÊÆ¡£
ÓÐÁ½ÖÖ·½Ê½£¬
µÚÒ»ÖÖÊÇÔÚÀà¼ÓÔØʱ¶¯Ì¬´¦Àí£¬Õâ¸ö¶ÔÏÖÓгÌÐò²»ÓÃÐ޸ġ£Ö»ÐèÒª¸ÄÏÂÔËÐеÄjava½Å±¾¼´¿É
¶ÔÓÚJava 1.5ÈçÏÂËùʾ
java -javaagent:lib/je-<version>.jar=enhance:packageNames ...
je-<version>.jar ¾ÍÊÇBerkeley DB JAVA¿âµÄÃû×Ö¡£ packageNa ......
Òì³£ÊÇÖ¸³ÌÐòÔËÐÐÆÚ¼ä³öÏÖµÄÎÊÌâ¡£ÔÚд³ÌÐòʱ£¬È·Êµ¿ÉÒÔд´úÂë²âÊÔ³ÌÐòÊÇ·ñÕýÈ·Ö´ÐУ¬Èç¹ûûÓÐÖ´ÐУ¬ÔòÖ´ÐдíÎó´¦Àí¡£¾¡¹ÜÕâÖÖÐÎʽµÄ´íÎó´¦ÀíÄܹ»Æðµ½×÷Ó㬵«³ÌÐòÂß¼Óë´íÎó´¦ÀíÒ»Æð»ìÓ㬻áʹµÃ³ÌÐòÄÑÒÔÔĶÁ‘Ð޸ġ£Èç¹ûDZÔÚµÄÎÊÌ⼫ÉÙ·¢Éú£¬Ôò»ìÓóÌÐòºÍ´íÎó´¦ÀíÂß¼½²½µµÍ³ÌÐòµÄÐÔÄÜ¡£Òì³£´¦Àíʹ³ÌÐòÔ±Äܹ»´Ó³ÌÐòÖ ......
ת£ºJavaѧϰ·Ïßͼ£¬×¨ÎªÐÂÊÖ¶¨ÖƵÄJavaѧϰ¼Æ»®½¨Òé ÊÕ²Ø ×ª×Ô£ºhttp://tieba.baidu.com/f?kz=692446591 ÔõôѧϰJava£¬ÕâÊǺܶàÐÂÊÖ¾³£»áÎÊÎÒµÄÎÊÌ⣬ÏÖÔÚÎÒ¼òµ¥ÃèÊöÏÂÒ»¸öJava³õѧÕßµ½¾ÍҵҪѧµ½µÄһЩ¶«Î÷£º Ê×ÏÈÒªÃ÷°×JavaÌåϵÉè¼Æµ½µÃÈý¸ö·½Ã棺J2SE,J2EE,J2ME£¨KJAVA£©¡£J2SE£¬Java 2 Platform Standard Edition£¬ ......
1.
BufferedReader in = new BufferedReader(new FileReader("Ô¶³ÌÎļþ"));
in.readLine() ;
l ʹÓà Java ²Ù×÷Îı¾ÎļþµÄ·½·¨Ïê½â
http://java.ccidnet.com/art/3737/20041108/523627_1.html
l FileReader ÊÇʲôÀࣿºÍ FileInputStream ÓÐʲô²»Í¬£¿£¿£¿
ht ......