JAVA socket ¹ØÓÚDNS »º´æ
ÔÚͨ¹ýDNS²éÕÒÓòÃûµÄ¹ý³ÌÖУ¬¿ÉÄܻᾹý¶ą̀ÖмäDNS·þÎñÆ÷²ÅÄÜÕÒµ½Ö¸¶¨µÄÓòÃû£¬Òò´Ë£¬ÔÚDNS·þÎñÆ÷ÉϲéÕÒÓòÃûÊǷdz£°º¹óµÄ²Ù×÷¡£ÔÚJavaÖÐΪÁË»º½âÕâ¸öÎÊÌ⣬ÌṩÁËDNS»º´æ¡£µ±InetAddressÀàµÚÒ»´ÎʹÓÃij¸öÓòÃû£¨Èçwww.csdn.net£©´´½¨InetAddress¶ÔÏóºó£¬JVM¾Í»á½«Õâ¸öÓòÃûºÍËü´ÓDNSÉÏ»ñµÃµÄÐÅÏ¢£¨ÈçIPµØÖ·£©¶¼±£´æÔÚDNS»º´æÖС£µ±ÏÂÒ»´ÎInetAddressÀàÔÙʹÓÃÕâ¸öÓòÃûʱ£¬¾ÍÖ±½Ó´ÓDNS»º´æÀï»ñµÃËùÐèµÄÐÅÏ¢£¬¶øÎÞÐèÔÙ·ÃÎÊDNS·þÎñÆ÷¡£
DNS»º´æÔÚĬÈÏʱ½«ÓÀÔ¶±£ÁôÔø¾·ÃÎʹýµÄÓòÃûÐÅÏ¢£¬µ«ÎÒÃÇ¿ÉÒÔÐÞ¸ÄÕâ¸öĬÈÏÖµ¡£Ò»°ãÓÐÁ½ÖÖ·½·¨¿ÉÒÔÐÞ¸ÄÕâ¸öĬÈÏÖµ£º
1. ÔÚ³ÌÐòÖÐͨ¹ýjava.security.Security.setProperty·½·¨ÉèÖð²È«ÊôÐÔnetworkaddress.cache.ttlµÄÖµ£¨µ¥Î»£ºÃ룩¡£ÈçÏÂÃæµÄ´úÂ뽫»º´æ³¬Ê±ÉèΪ10Ã룺
java.security.Security.setProperty("networkaddress.cache.ttl", 10);
2. ÉèÖÃjava.securityÎļþÖеÄnetworkaddress.cache.negative.ttlÊôÐÔ¡£¼ÙÉèJDKµÄ°²×°Ä¿Â¼ÊÇC£º\jdk1.6£¬ÄÇôjava.securityÎļþλÓÚc£º\jdk1.6\jre\lib\securityĿ¼ÖС£´ò¿ªÕâ¸öÎļþ£¬ÕÒµ½networkaddress.cache.ttlÊôÐÔ£¬²¢½«Õâ¸öÊôÐÔÖµÉèΪÏàÓ¦µÄ»º´æ³¬Ê±£¨µ¥Î»£ºÃ룩¡£
Èç¹û½«networkaddress.cache.ttlÊôÐÔÖµÉèΪ-1£¬ÄÇôDNS»º´æÊý¾Ý½«ÓÀÔ¶²»»áÊÍ·Å¡£ÏÂÃæµÄ´úÂëÑÝʾÁËʹÓúͲ»Ê¹ÓÃDNS»º´æËù²úÉúЧ¹û£º
package mynet;
import java.net.*;
public class MyDNS
{
public static void main(String[] args) throws Exception
{
// args[0]: ±¾»úÃû args[1]£º»º³åʱ¼ä
if (args.length < 2)
return;
java.security.Security.setProperty("networkaddress.cache.ttl", args[1]);
long time = System.currentTimeMillis();
InetAddress addresses1[] = InetAddress.getAllByName(args[0]);
System.out.println("addresses1: "
 
Ïà¹ØÎĵµ£º
³ÌÐòÖеıàÂë·ç¸ñÈÃÎÒÃǵıà³Ì¹¤×÷±äµÃÇáËÉ£¬ÌرðÊdzÌÐòά»¤Ô±£¬ËûÃÇÒª¾³£ÔĶÁÆäËûÈ˱àдµÄ³ÌÐò±àÂ룬ÕâÒ»µãÓÈÆäÍ»³ö¡£±àÂë¹æ·¶´Ó¸ù±¾ÉϽâ¾öÁ˳ÌÐòά»¤Ô±µÄÄÑÌ⣻¹æ·¶µÄ±àÂëÔĶÁºÍÀí½âÆðÀ´¸üÈÝÒ×£¬Ò²¿ÉÒÔ¿ìËٵIJ»·ÑÁ¦ÆøµÄ½è¼ø±ðÈ˵ıàÂë¡£¶Ô½«À´Î¬»¤Äã±àÂëµÄÈËÀ´Ëµ£¬ÄãµÄ±àÂëÔ½ÓÅ»¯£¬ËûÃǾÍԽϲ»¶ÄãµÄ±àÂ룬Àí½âÆðÀ´Ò²¾ÍÔ½ ......
Ó¢ÎÄÍøÕ¾
http://www.javaalmanac.com - Java¿ª·¢ÕßÄê¼øÒ»ÊéµÄÔÚÏß°æ±¾£¬ÏëÒª¿ìËٲ鵽ijÖÖJava¼¼ÇɵÄÓ÷¨¼°Ê¾ÀýµÄ´úÂëÕâÊÇÒ»¸ö²»´íµÄÈ¥´¦.
http://www.onjava.com - O'ReillyµÄJavaÍøÕ¾. ÿÖܶ¼ÓÐÐÂÎÄÕÂ.
http://java.sun.com - ¹Ù·½µÄJava¿ª·¢ÕßÍøÕ¾ - ÿÖܶ¼ÓÐÐÂÎÄÕ·¢±í.
http://www.developer.com/java - ÓÉGamelan ......
¡¾51CTO¾«Ñ¡ÒëÎÄ¡¿ÔÚ±¾ÆªÎÄÕÂÖУ¬ÖøÃû³ÌÐòÔ±Justin JamesÌÖÂÛÁËJavaµÄδÀ´£¬ÒÔ¼°JavaÓë.NETµÄ¿ª·¢³É±¾¶Ô±È£¬ºÍJavaÊÇ·ñÄܹ»È¡´ú.NET¡£JustinÔÚÎÄÖÐ×ܽáÁËËÄ´óÒªµã£¬Öصã¹Ø×¢ÁËÁ½¸öÔËÐÐʱÔÚÐÔÄܺͳɱ¾ÉϵÄÒì֮ͬ´¦¡£
1¡¢Java SE 7ÔâÓö.NET CLR»á·¢Éúʲô£¿
´ÓJava SE 7µÄ¹¦ÄÜÁбíÖпÉÒÔ¿´³ö£¬ËüÏà±ÈÒÔÇ°°æ±¾ÓÐÁ˳¤×ãÌá¸ß¡£ ......
volatile¹Ø¼ü×ÖÓÐʲôÓã¿
¿ÖűȽÏÒ»ÏÂvolatileºÍsynchronizedµÄ²»Í¬ÊÇ×îÈÝÒ×½âÊÍÇå³þµÄ¡£volatileÊDZäÁ¿ÐÞÊηû£¬¶øsynchronizedÔò×÷ÓÃÓÚÒ»¶Î´úÂë»ò·½·¨£»¿´ÈçÏÂÈý¾äget´úÂ룺
int i1; ......
JAVAËÄÖÖ»ù±¾ÅÅÐò,°üÀ¨Ã°ÅÝ·¨,²åÈë·¨,Ñ¡Ôñ·¨,SHELLÅÅÐò·¨.ÆäÖÐÑ¡Ôñ·¨ÊÇðÅÝ·¨µÄ¸Ä½ø,SHELLÅÅÐò·¨ÊÇ ²åÈë·¨µÄ¸Ä½ø.ËùÒÔ´Ó¸ù±¾ÉÏÀ´Ëµ¿ÉÒÔ¹éÄÉΪÁ½ÖÖ²»Í¬µÄÅÅÐò·½·¨:¼´:²åÈë·¨£¦Ã°ÅÝ·¨¡£
Ò»¡¢ ²åÈë·¨
¡¡¡¡±éÀúÅÅÐò¼¯ºÏ£¬Ã¿µ½Ò»¸öÔªËØʱ£¬¶¼Òª½«Õâ¸öÔªËØÓëËùÓÐËü֮ǰµÄÔªËرéÀú±È½ÏÒ»±é£¬È÷ûºÏÅÅÐò˳ÐòµÄÔªËØ°¤¸öÒƶ¯µ½µ±Ç°· ......