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

Java Serializable£¨ÐòÁл¯£©µÄÀí½âºÍ×ܽá

1¡¢ÐòÁл¯ÊǸÉʲôµÄ£¿
       ¼òµ¥Ëµ¾ÍÊÇΪÁ˱£´æÔÚÄÚ´æÖеĸ÷ÖÖ¶ÔÏóµÄ״̬£¨Ò²¾ÍÊÇʵÀý±äÁ¿£¬²»ÊÇ·½·¨£©£¬²¢ÇÒ¿ÉÒ԰ѱ£´æµÄ¶ÔÏó״̬ÔÙ¶Á³öÀ´¡£ËäÈ»Äã¿ÉÒÔÓÃÄã×Ô¼ºµÄ¸÷ÖÖ¸÷ÑùµÄ·½·¨À´±£´æobject states£¬µ«ÊÇJava¸øÄãÌṩһÖÖÓ¦¸Ã±ÈÄã×Ô¼ººÃµÄ±£´æ¶ÔÏó״̬µÄ»úÖÆ£¬ÄǾÍÊÇÐòÁл¯¡£
2¡¢Ê²Ã´Çé¿öÏÂÐèÒªÐòÁл¯  
    a£©µ±ÄãÏë°ÑµÄÄÚ´æÖеĶÔÏó״̬±£´æµ½Ò»¸öÎļþÖлòÕßÊý¾Ý¿âÖÐʱºò£»
    b£©µ±ÄãÏëÓÃÌ×½Ó×ÖÔÚÍøÂçÉÏ´«ËͶÔÏóµÄʱºò£»
    c£©µ±ÄãÏëͨ¹ýRMI´«Êä¶ÔÏóµÄʱºò£»
3¡¢µ±¶ÔÒ»¸ö¶ÔÏóʵÏÖÐòÁл¯Ê±£¬¾¿¾¹·¢ÉúÁËʲô£¿
    ÔÚûÓÐÐòÁл¯Ç°£¬Ã¿¸ö±£´æÔڶѣ¨Heap£©ÖеĶÔÏó¶¼ÓÐÏàÓ¦µÄ״̬£¨state£©£¬¼´ÊµÀý±äÁ¿£¨instance ariable£©±ÈÈ磺
   
java ´úÂë
Foo  myFoo = new Foo();  
myFoo .setWidth(37);  
myFoo.setHeight(70);  
     
       µ± ͨ¹ýÏÂÃæµÄ´úÂëÐòÁл¯Ö®ºó£¬MyFoo¶ÔÏóÖеÄwidthºÍHeightʵÀý±äÁ¿µÄÖµ£¨37£¬70£©¶¼±»±£´æµ½foo.serÎļþÖУ¬ÕâÑùÒÔºóÓÖ¿ÉÒÔ°ÑËü ´ÓÎļþÖжÁ³öÀ´£¬ÖØÐÂÔÚ¶ÑÖд´½¨Ô­À´µÄ¶ÔÏó¡£µ±È»±£´æʱºò²»½ö½öÊDZ£´æ¶ÔÏóµÄʵÀý±äÁ¿µÄÖµ£¬JVM»¹Òª±£´æһЩСÁ¿ÐÅÏ¢£¬±ÈÈçÀàµÄÀàÐ͵ÈÒÔ±ã»Ö¸´Ô­À´µÄ¶Ô Ïó¡£
java ´úÂë
FileOutputStream fs = new FileOutputStream("foo.ser");  
ObjectOutputStream os = new ObjectOutputStream(fs);  
os.writeObject(myFoo);  
4¡¢ÊµÏÖÐòÁл¯£¨±£´æµ½Ò»¸öÎļþ£©µÄ²½Öè
       a£©Make a FileOutputStream            
java ´úÂë
FileOutputStream fs = new FileOutputStream("foo.ser");    
       b£©Make a ObjectOutputStream           
java ´úÂë
ObjectOutputStream os =  new ObjectOutputStream(fs);   
       c£©write the object
java ´úÂë
os.writeObject


Ïà¹ØÎĵµ£º

JavaÖеÄÀàÐÍת»»


±¾×÷Æ·²ÉÓÃ֪ʶ¹²ÏíÊðÃû-·ÇÉÌÒµÐÔʹÓÃ-Ïàͬ·½Ê½¹²Ïí 2.5 Öйú´ó½Ðí¿ÉЭÒé½øÐÐÐí¿É¡£
ÎÞÂÛÔÚC/C++»¹ÊÇÔÚJava£¬Ç¿ÖÆÀàÐÍת»»ÒѾ­²»ÊÇÄ°ÉúµÄ¸ÅÄîÁË¡£µ«ÊÇÒªÏëÈ«ÃæÕÆÎÕJavaÖÐÀàÐÍת»»µÄÒªµã¿É²»ÄÇô¼òµ¥£¬±¾ÎĽ«´øÁì´ó¼ÒһͬÁ˽âÓйØJavaÀàÐÍת»»µÄËùÓÐÒªµã¡£
ÊýÖµÀàÐ͵ÄÀàÐÍת»»
ÖÚËùÖÜÖª£¬JavaÓÐÁ½ÖÖÊý¾ÝÀàÐÍ£º»ù±¾Êý¾Ý ......

Java Network Game Programming

game
server responsibility:
Initialize
the server socke;

Wait
for a client to connect;

Accept
the client connection;

Create
a daemon thread to support the clien;

Go
back to step 2.

game daemon responsibility:
Accept
client player connection;

Pair ......

java¶þ·Ö²éÕÒ

¶þ·Ö²éÕÒ£º
   ¶þ·Ö²éÕÒ±ÈÏßÐÔ²éÕÒÊý¶ÈÒªºÃºÜ¶à£¬ÓÈÆäÊǶԴóÊý×éÀ´Ëµ¸üΪÏÔÖø£¬¾ÍÏñÊDzÂ×ÖÓÎÏ·Ò»Ñù
²Â×ÖÓÎÏ·£º
   ¶þ·Ö²éÕҵķ½·¨ºÍÎÒÃÇСʱºòÍæµÄ²Â×ÖÓÎÏ·ÊÇÒ»ÑùµÄ¡£ÔÚÕâ¸öÓÎÏ·ÀïÃ棬ÓÐÒ»¸öСÅóÓÑ»áÈÃÄã²ÂËýÕýÔÚÏëµÄÒ»¸ö1ÖÁ100Ö®¼äµÄÊý£¬
Äã²ÂÁËÒ»¸öÊýÒÔºó£¬Ëý»á¸æËßÄãÈýÖÖÑ¡ÔñÖеÄÒ»¸ö£ºÄã² ......

Java¶àÏ̱߳à³ÌÖеÄSynchronized

Synchronized£¬¹ËÃû˼Ò壬´ú±í¶à¸öÏß³ÌÖ®¼äµÄͬ²½¡£ÄÇô£¬ÔÚjava±à³ÌÖÐÈçºÎʹÓÃËüÄØ£¿ ÎÒÃǼÙÉèÕâÑùÒ»¸öÇé¿ö£º¶ÔÓÚͬһ¸ö±äÁ¿synDemo£¬ÎÒÃÇ·Ö±ðÔÚ2¸ö²»Í¬µÄÏß³ÌÖе÷ÓÃsynDemo.synMethord1()ÓësynDemo.synMethord2()¡£ package com.cnblogs.gpcuster;
/**
*
* @author Aaron.Guo
*
*/
public class Tester { ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ