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

ת£ºÌ½Ë÷ Java ͬ²½»úÖÆ

̽Ë÷ Java ͬ²½»úÖÆ http://www.ibm.com/developerworks/cn/java/j-lo-synchronized/ Monitor Object ²¢·¢Ä£Ê½ÔÚ Java ͬ²½»úÖÆÖеÄʵÏÖ    ¼¶±ð£º Öм¶ Àî Èýºì (lisanh@cn.ibm.com), ¸ß¼¶Èí¼þ¹¤³Ìʦ, IBM 2008 Äê 12 Ô 26 ÈÕ
±¾ÎÄ´ÓµäÐ굀 Monitor Object Éè¼ÆģʽÈëÊÖ£¬´ÓÒ»¸öеÄÊӽǣ¬À´Ì½ÌÖ Java ÓïÑÔµÄͬ²½»úÖÆ¡£ ±¾ÎĽ«´ÓÁ½¸ö·½Ãæ½øÐвûÊö:
ʹÓà C++ ÓïÑÔÀ´ÃèÊö Monitor Object Éè¼Æģʽ¡£Java ¶ÔÓÚÕâÑùÒ»¸öµäÐ͵Äģʽ×öÁ˺ܺõÄÓïÑÔ²ãÃæµÄ·â×°£¬Òò´Ë¶ÔÓÚ Java µÄ¿ª·¢ÕßÀ´Ëµ£¬ºÜ¶à¹ØÓÚ¸Ãģʽ±¾ÉíµÄ¶«Î÷±»ÆÁ±ÎµôÁË¡£±¾ÎÄÊÔͼʹÓà Native C++ ÓïÑÔ£¬°ïÖú¶ÁÕß´Ó±¾ÖÊÉÏ¶Ô Monitor object Éè¼ÆģʽÓÐÒ»¸ö¸üÈ«ÃæµÄÈÏʶ¡£
½áºÏ C++ °æ±¾µÄ Monitor Object Éè¼Æģʽ£¬ÒýÁì¶ÁÕ߶ÔÓÚ Java ͬ²½»úÖÆÓÐÒ»¸ö¸üÉî¿ÌµÄÈÏʶ£¬°ïÖú¶ÁÕßÕýÈ·ÓÐЧµØʹÓà Java ͬ²½»úÖÆ¡£ Ô¤±¸ÖªÊ¶ ÔÚ¿ªÊ¼ÕýʽÌÖÂÛ֮ǰ£¬ÐèÒªÁ˽âһЩԤ±¸ÖªÊ¶¡£ ʲôÊÇ RAII ×ÊÔ´»ñÈ¡¼´³õʼ»¯£¨RAII, Resource Acquisition Is Initialization£©ÊÇÖ¸£¬ÔÚÒ»¸ö¶ÔÏóµÄ¹¹Ô캯ÊýÖлñµÃ×ÊÔ´ , ²¢ÇÒÔڸöÔÏóµÄÎö¹¹º¯ÊýÖÐÊÍ·ÅËü¡£Õâ¸ö×ÊÔ´¿ÉÒÔÊǶÔÏó¡¢ÄÚ´æ¡¢Îļþ¾ä±ú»òÕßÆäËüÀàÐÍ¡£ÊµÏÖÕâÖÖ¹¦ÄܵÄÀ࣬ÎÒÃǾÍ˵Ëü²ÉÓÃÁË×ÊÔ´»ñÈ¡¼´³õʼ»¯£¨RAII£©µÄ·½Ê½¡£ RAII ÊÇÒ»ÖֺܵäÐ͵ÄÓïÑÔ¹ßÓ÷¨£¬±»ºÜ¶àµÄ OO ÓïÑÔËùʹÓã¬ÏÂÃæÊÇ C++ µÄÀý×Ó¡£ Çåµ¥ 1. RAII Using C++               
class Raii {
public:
    // Store a pointer to the resource and initialize the resource.
    Raii(Resource &resource)
    :m_pRes (&resource){
        m_pRes->initialize ();
    }
    // Close the resource when the execution goes out of scope.
    virtual ~Raii() {
        m_pRes->close ();
    }
private:
    // Pointer to the resource we're managing.
    Resource *m_pRes;
    // ... maybe need disallow copying and assignment ...


Ïà¹ØÎĵµ£º

java ioϵͳʵÀý½²½â

      ÔÚJAVAÖнøÐÐÎļþµÄ¶Áд²Ù×÷Ö÷ÒªÓõ½ÁËJAVAÖеÄÊäÈëÊä³ö£¨IO£©API£¬Java I/OÌṩÁËÐí¶àAPIÌṩ¶ÔÎļþ£¬Äڴ棬socketµÄ¶ÁдµÈ£¬±¾ÎÄÖ÷Ҫͨ¹ýʵÀýÀ´½²½âÔõÑùÀí½âjavaÖеÄÊäÈëÊä³ö¡£
Ò»£¬»ù±¾¸ÅÄî
   Á÷£¨Stream£©£º
  Á÷ÊÇÒ»ÖÖÓÐÐòµÄ×Ö½ÚÊý¾Ý¶ÔÏó¡£Á÷ÓÖ·ÖΪÊäÈëÁ ......

JAVA ¶¨Ê±Æ÷

(1)Timer.schedule(TimerTask task,Date time)°²ÅÅÔÚÖƶ¨µÄʱ¼äÖ´ÐÐÖ¸¶¨µÄÈÎÎñ¡£
(2)Timer.schedule(TimerTask task,Date firstTime ,long period)°²ÅÅÖ¸¶¨µÄÈÎÎñÔÚÖ¸¶¨µÄʱ¼ä¿ªÊ¼½øÐÐÖظ´µÄ¹Ì¶¨ÑÓ³ÙÖ´ÐУ®
(3)Timer.schedule(TimerTask task,long delay)°²ÅÅÔÚÖ¸¶¨ÑÓ³ÙºóÖ´ÐÐÖ¸¶¨µÄÈÎÎñ£®
(4)Timer.schedule(TimerTask ......

JavaȨÏÞ¿ØÖƵÄËã·¨

ÕâÀï±ÊÕß½éÉÜÒ»Öֺܳ£Óã¬Ò²±È½ÏרҵµÄȨÏÞ¿ØÖÆ˼·¡£ÕâÀïÓÃjavaÓïÑÔÃèÊö£¬Æäʵ¶¼²î²»¶àµÄ¡£Òª»»³ÉÆäËûµÄÓïÑÔÖ÷£¬×Ô¼º×ªÒ»Ï¾ͿÉÒÔÁË¡£ÎªÁË·½±ãÆð¼û£¬ÎÒÃÇÕâÀﶨÒåa^bΪ£ºaµÄb´Î·½¡£ÕâÀÎÒÃÇΪÿһ¸ö²Ù×÷É趨һ¸öΨһµÄÕûÊýÖµ£¬±ÈÈ磺
ɾ³ý£Á£­£­£­0
Ð޸ģÁ£­£­£­1
Ìí¼Ó£Á£­£­£­2
 
ɾ³ý£Â£­£­£­3
Ð޸ģ£­£­£ ......

JavaÉϵı¦Ê¯ JRuby 1.5Õýʽ·¢²¼

JavaÉϵı¦Ê¯ JRuby 1.5Õýʽ·¢²¼
2010Äê05ÔÂ12ÈÕ£¬JRubyÍŶӷdz£¸ßÐ˵ÄÐû²¼1.5.0°æµÄ·¢²¼¡£ÔÚÕâ֮ǰ£¬Ôø¾­·¢²¼¹ýJRuby 1.5.0 RC1µÄ·¢²¼ÏûÏ¢£¬Ïà±È֮ϣ¬Õýʽ·¢²¼±¾±¾ÓÖÌṩÁ˺ܶà¸üС£
JRuby 1.5.0 °æ±¾µÄÖ÷Ò³ºÍÏÂÔصØÖ··Ö±ðÊÇ£º
Ö÷Ò³£ºhttp://www.jruby.org/
ÏÂÔØ£ºhttp://www.jruby.org/download
Õâ´Î·¢²¼ÊÇJRubyÀú ......

Java IO¿ò¼Ü

¿É´ÓIOµÄÀà²ã´Î£¬IO¿ò¼ÜµÄÉè¼ÆģʽÀ´ÂÛÊö¡£
×ÜÌåÀ´Ëµ£¬IO¿ÉÒÔ·ÖΪ×Ö½ÚÁ÷ºÍ×Ö·ûÁ÷£¬²»Í¬ÔÚÓÚ×Ö·ûÁ÷ÓÉ×Ö½ÚÁ÷°ü×°¶øÀ´£¬ÔÚIO¶ÁÈëÖ®ºó¾­¹ýJVM´¦Àí£¬°Ñ×Ö½ÚÁ÷ת»»³É×Ö·ûÁ÷¡£¶ø×Ö·ûÁ÷µÄ×Ö·û²ÉÓÃÄÄÖÖ×Ö·û±àÂëʵÏÖÓÉJVMĬÈϱàÂë¾ö¶¨¡£
¶øÿ¸öÁ÷¶¼·ÖÊäÈëºÍÊä³ö£¬ËùÒÔ£¬×ÜÌåÀ´Ëµ£¬IOÓÐËĸö¶¥²ãÀࣺ
InputStream
OutputStream ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ