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

java socket¶àÏß³Ì ½ÓÊÕxml

java socket¶àÏß³Ì ½ÓÊÕxml
2009-08-21 17:25
Õâ¶Îʱ¼ä×öÁ˸öÏîÄ¿£¬²»¹ý¾õµÃÒ»Ö±ÊÇÎÒÔÚд£¬ÎÒÃÇ×ܼàÔٸġ£¡£¿´Ñù×Ó×Ô¼ºµÄ´úÂëÄÜÁ¦Ì«²îÁË¡£¶øÇÒÂÒÆß°ËÔãµÄÀ²¡£¡£
ÏÖ½«´úÂë·ÖÏíÒ»Ï塃 £ºÊÇ´Ó¿Í»§¶Ë½ÓÊÕxml½øÐÐÒ»¶¨µÄ½âÎö£¬È»ºóÈë¿â×îºó·µ»Ø°É Öм临ÔÓµÄÂß¼­¾Í²»ËµÁË ¡£¡£¡£
SocketServer.java
package com.socket;
import java.io.IOException;
import java.net.*;
import
java.util.concurrent.*;
import com.Config;
import org.apache.log4j.Logger;
public class SocketServer {
   
    Config c = new Config();
   
private static Logger logger = Logger.getLogger(SocketServer.class);
   
private ServerSocket serverSocket;
    private ExecutorService
executorService;//Ï̳߳Ø
    private final int POOL_SIZE =
100;//µ¥¸öCPUÏ̳߳شóС
    public SocketServer() throws IOException {
       
serverSocket = new ServerSocket(c.port);
       
//RuntimeµÄavailableProcessor()·½·¨·µ»Øµ±Ç°ÏµÍ³µÄCPUÊýÄ¿.
        executorService =
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() *
POOL_SIZE);
        System.out.println("·þÎñÆ÷Æô¶¯");
       
logger.debug("service start!!");
    }
    public void service() {
        while (true) {
            Socket
socket = null;
            try {
               
//½ÓÊÕ¿Í»§Á¬½Ó,Ö»Òª¿Í»§½øÐÐÁËÁ¬½Ó,¾Í»á´¥·¢accept();´Ó¶ø½¨Á¢Á¬½Ó
                socket =
serverSocket.accept();
   &


Ïà¹ØÎĵµ£º

javaÈëÃÅ

 Javaѧϰ´ÓÈëÃŵ½¾«Í¨ 
Ò»¡¢ JDK (Java Development Kit) 
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......

½âÎöJavaÀàºÍ¶ÔÏóµÄ³õʼ»¯¹ý³Ì

ÀàµÄ³õʼ»¯ºÍ¶ÔÏó³õʼ»¯ÊÇ JVM ¹ÜÀíµÄÀàÐÍÉúÃüÖÜÆÚÖзdz£ÖØÒªµÄÁ½¸ö»·½Ú£¬Google ÁËÒ»±éÍøÂ磬ÓйØÀà×°ÔØ»úÖÆµÄÎÄÕµ¹ÊDz»ÉÙ£¬È»¶øÀà³õʼ»¯ºÍ¶ÔÏó³õʼ»¯µÄÎÄÕ²¢²»¶à£¬ÌرðÊÇ´Ó×Ö½ÚÂëºÍ JVM ²ã´ÎÀ´·ÖÎöµÄÎÄÕ¸üÊÇÏÊÓÐËù¼û¡£
±¾ÎÄÖ÷Òª¶ÔÀàºÍ¶ÔÏó³õʼ»¯È«¹ý³Ì½øÐзÖÎö£¬Í¨¹ýÒ»¸öʵ¼ÊÎÊÌâÒýÈ룬½«Ô´´úÂëת»»³É JVM ×Ö½ÚÂëºó£¬ ......

´«ÖDz¥¿Í2009 12 24 Èý¡¢java»ù´¡¼ÓÇ¿(3)


Ò»¡¢·ºÐÍ(Generic)
       JDK5ÒÔǰ£¬¶ÔÏó±£´æµ½¼¯ºÏÖоͻáʧȥÆäÌØÐÔ£¬È¡³öʱͨ³£Òª³ÌÐòÔ±ÊÖ¹¤½øÐÐÀàÐ͵ÄÇ¿ÖÆ×ª»»£¬ÕâÑù²»¿É±ÜÃâ¾Í»áÒý·¢³ÌÐòµÄһЩ°²È«ÐÔÎÊÌâ
Ø·ºÐεÄ×÷Óãº
       JDK5ÖеķºÐÎÔÊÐí³ÌÐòÔ±ÔÚ±àд¼¯ºÏ´úÂëʱ£¬¾ÍÏÞÖÆ¼¯ºÏµÄ´¦ÀíÀ ......

Java½âÎöÍøÂçÊý¾ÝÁ÷µÄÈýÖÖÌØÊâ·½·¨

UTF8ת»»³ÉGB2312 µ±ÎÒÃÇÔÚ»ùÓÚHTTPЭÒéµÄJSP»òServletµÄÓ¦ÓÃÖлñÈ¡Êý¾Ý»ò·¢ËÍÇëÇóʱ£¬JVM»á°ÑÊäË͵ÄÊý¾Ý±àÂë³ÉUTF8¸ñʽ¡£Èç¹ûÎÒÃÇÖ±½Ó´ÓHTTPÁ÷ÖÐÌáÈ¡ÖÐÎÄÊý¾Ý£¬ÌáÈ¡µÄ½á¹ûΪ“????”£¨¿ÉÄܸü¶àÎʺţ©£¬Îª×ª»»³ÉÎÒÃÇÄܹ»Àí½âµÄÖÐÎÄ×Ö·û£¬ÎÒÃÇÐèÒª°ÑUTF8ת»»³ÉGB2312£¬½èÖúISO-8859-1±ê×¼±àÂëÄܹ»ÇáÒ×µÄʵÏÖ£¬ÏÂÃæ ......

finalÔÚjavaÖеÄÓ¦ÓÃ

finalÔÚJavaÖв¢²»³£Óã¬È»¶øËüȴΪÎÒÃÇÌṩÁËÖîÈçÔÚCÓïÑÔÖж¨Òå³£Á¿µÄ¹¦ÄÜ£¬²»½öÈç´Ë£¬final»¹¿ÉÒÔÈÃÄã¿ØÖÆÄãµÄ³ÉÔ±¡¢·½·¨»òÕßÊÇÒ»¸öÀàÊÇ·ñ¿É±»¸²Ð´»ò¼Ì³ÐµÈ¹¦ÄÜ£¬ÕâÐ©ÌØµãʹfinalÔÚJavaÖÐÓµÓÐÁËÒ»¸ö²»¿É»òȱµÄµØÎ»£¬Ò²ÊÇѧϰJavaʱ±ØÐëÒªÖªµÀºÍÕÆÎյĹؼü×ÖÖ®Ò»¡£
final³ÉÔ±
¡¡¡¡ µ±ÄãÔÚÀàÖж¨Òå±äÁ¿Ê±£¬ÔÚÆäÇ°Ãæ¼ÓÉÏfi ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ