java Ï̵߳ÄÉè¼Æģʽ
¾Í¶àÏß³ÌÀ´Ëµ£¬ÎÒÃÇ¿ªÊ¼ÉèÏëÖ»ÓÐÁ½¸öỊ̈߳¨>2ʱÊDz»ÊÇËãÊýѧ¹éÄÉ·¨£¿£©ÄÇôÈç¹ûÁ½¸ö¶ÀÁ¢µÄÏ̻߳ᷢÉúʲôÄØ£¿
1¡£µ±Ò»¸öÏ߳̽øÈëmoniter£¨Ò²¾ÍÊÇ˵վÓÃÒ»¸öobject£©£¬ÁíÒ»¸öÏß³ÌÖ»Óеȴý»ò·µ»Ø£¬¶øÎÒÃÇ°Ñ·µ»Ø¾Í³ÆΪһÖÖģʽ£¬ÕâÖÖģʽµÄÓ¢ÎÄÊÇBalking¡£
2¡£ÕâÁ½¸öÏ߳̿ÉÒÔÊÇÓÐÐòµÄÖ´ÐУ¬¶ø²»ÊÇÈÃOSÀ´µ÷¶È£¬ÕâʱÎÒÃÇÒªÓÃÒ»¸öobjectÀ´µ÷¶È£¬ÕâÖÖģʽ³ÆΪScheduler¡££¨Õâ¸ö´Ê¼°Æ京ÒåÆäʵOSÖоÍÓУ©¡£
3¡£Èç¹ûÕâÁ½¸öÏß³Ìͬʱ¶ÁÒ»¸ö×ÊÔ´£¬ÎÒÃÇ¿ÉÒÔÈÃËûÃÇÖ´ÐУ¬µ«Èç¹ûͬʱдµÄ»°£¬Äã±Õ×ÅÑÛ¾¦¶¼»áÖªµÀ¿ÉÄܳöÏÖÎÊÌ⣬ÕâʱÎÒÃǾÍÒªÓÃÁíÒ»ÖÖģʽ£¨Read/Write Lock£©¡£
4¡£Èç¹ûÒ»¸öÏß³ÌÊÇΪÁíÒ»¸öÏ̷߳þÎñµÄ»°£¬±ÈÈçIEÖиºÔðÊý¾Ý´«ÊäµÄÏ̺߳ͽçÃæÏÔʾµÄỊ̈߳¬µ±Ò»¸öͼƬûÓд«Íêʱ£¬ÁíÒ»¸öÏ߳̾ÍÎÞ·¨ÏÔʾ£¬ÖÁÉÙÊDz¿·ÖûÓд«Íê¡£ÄÇôÕâʱÎÒÃÇÒªÓÃÒ»¸öģʽ³ÆΪÉú²úÕߺÍÏû·ÑÕߣ¬Ó¢ÎÄÊÇProducer-Consumer¡£
5¡£Á½¸öÏ̵߳ÄÏûÍöÒ²¿ÉÒÔ²»ÊÇÍêÈ«ÓÖOSÀ´¿ØÖƵģ¬ÕâʱÎÒÃÇÐèÒª¸ø³öÒ»¸öÌõ¼þ£¬Ê¹µÃÿ¸öÏß³ÌÔÚ·ûºÏÌõ¼þÊDzÅÏûÍö£¬Ò²¾ÍÊÇÓÐÐòµÄÏûÍö£¬ÎÒÃdzÆΪTwo-Phase Termination¡£
ÄÇôÓÐÕâ5¸öÏß³ÌÄ£ÐÍ£¬»ù±¾ÉÏ¿ÉÒÔÓõ½´ó¶àÊý±à³ÌÈÎÎñÖС£ÎÒÐèÒªÖ¸³öµÄÈýµãÊÇ£º
1¡£´Ó¸ß²ã´ÎÉÏÎÒÃÇ¿ÉÒÔÔÙÑéÖ¤ÊÇ·ñº¬¸ÇÁËËùÓеÄÇé¿ö¡£
2¡£Æäʵģʽ²»ÊÇÍêÈ«¹Ì¶¨µÄ»òÕß˵Ïó¶¨ÂÉÒ»Ñù£¬¶øģʽ¿ÉÒÔΪ²»Í¬µÄÇé¿ö½øÐÐÊʵ± µÄµ÷ÕûºÍ×éºÏ£¬Ä¿µÄÊÇΪÁ˼ò½àºÍ¸ßЧ¡£
3¡£Ñ§Ï°Ä£Ê½ÊÇΪÁ˾߱¸¸üºÃµÄ·ÖÎöÎÊÌâµÄÄÜÁ¦¡£
¶øËƺõÕâЩÀ´×ÔÎ÷·½µÄ¼¼Êõ£¬²¢ÇÒÊÇÄ¿Ç°µÄ£¬ÎÒÃÇÓÐûÓÐÄØ£¿ÆäʵÎÒ¸öÈËÓиö´óµ¨µÄÍƲ⣬ÎÒÈÏΪÎÒÃÇ×æÏȵġ¶Ëï×Ó±ø·¨¡·¾ÍÊǺܺÃÉè¼Æģʽ£¬ÒòΪËü·ûºÏÉè¼ÆģʽÐèÒªµÄ»ù±¾ÌØÕ÷£¬¾ÍÊÇÔÚÌض¨µÄÌõ¼þÏ£¬ÓÃijÖÖÌض¨µÄ·½Ê½ºÏÀíÇÒ¸ßЧµÄ½â¾öÎÊÌâ¡£Ö»²»¹ýÒ»ÊÇÓÃÔÚ¾üÊÂÉÏ£¬¶þÊÇÍ걸ÐÔ·½ÃæÎÒÃÇ»¹Ã»Ñо¿¡£µ«ÎÒÈÏΪÎÒÃÇÖÁÉÙûÓкܺõÄÀ©Õ¹ºÍ½øÐÐÀà±ÈʽµÄÓ¦Ó㬷ñÔò½ñÌì¿ÉÄÜÊÇÎÒÃÇÖйúÈ˽ÌÍâ¹úÈËʲôÊÇÉè¼Æģʽ¡£
Àà±ÈµÄ·½·¨Êµ¼ÊÉÏÊÇ·¢Ã÷»ò·¢Ïֵij£Ó÷½·¨¡£²»ÖªÄÜ·ñÈÃÄã¸Ð¾õµ½ÆäʵÍâ¹úµÄ¼¼Êõ²¢²»ÊÇÄÇôµÄÉñÃØ£¬Ò²ÐíÎÒÃÇ´Ó×ÔÉíµÄÎÄ»¯µ±ÖÐÍÚ¾ò³öµÄ¶«Î÷Ì«ÉÙÁË¡£
P.S.¸üÉîÒ»²½µÄÑо¿Äã¿ÉÒԲο¼Doug Lea. <<Concurrent Programming in Java>>.
Ïà¹ØÎĵµ£º
JAVA³£ÓÃÀàµÄʹÓ÷½·¨
£±¡¢IntegerÀà
£²¡¢FloatÀà
£³¡¢DoubleÀà
£´¡¢CharacterÀà
£µ¡¢StringÀà
£¶¡¢StringTokenizerÀà
£·¡¢StringBufferÀà
£¸¡¢RandomÀà
1£®IntegerÀàµÄʹÓ÷½·¨
Interger£ºÕûÊýÀàÐÍ
£±¡¢ÊôÐÔ¡£
static int MAX_VALUE£º·µ»Ø×î´óµÄÕûÐÍÊý£»
static int MIN_VALUE£º·µ»Ø×îСµÄÕûÐÍÊý£»
static C ......
Ò»¡¢Îª´úÂë¼Ó×¢ÊÍ¡£ËäȻÿ¸öÈ˶¼ÖªµÀÕâµã£¬µ«ÓÐʱȴ²»×Ô¾õÍüÁËÂÄÐУ¬½ñÌìÄã“ÍüÁË”¼Ó×¢ÊÍÁËÂð£¿ËäÈ»×¢ÊͶԳÌÐòµÄ¹¦ÄÜûʲô“¹±Ï×”£¬µ«¹ýÒ»¶Îʱ¼ä£¬±ÈÈç˵Á½ÐÇÆÚÖ®ºó»òÕ߸ü³¤£¬»Ø¹ýÍ·À´¿´¿´×Ô¼ºµÄ´úÂ룬˵²»¶¨ÒѾ¼Ç²»×¡ËüÊǸÉʲôµÄÁË¡£Èç¹ûÕâЩ´úÂëÊÇÄã¸öÈ˵ģ¬ÄÇ»¹ËãÊÇ×ßÔËÁË£¬²»ÐÒµÄÊÇ£¬µ± ......
JAVA¿ª·¢Õß×ȥµÄ20¸öÓ¢ÎÄÍøÕ¾
1.[http://www.javaalmanac.com] – Java¿ª·¢ÕßÄê¼øÒ»ÊéµÄÔÚÏß°æ±¾. ÒªÏë¿ìËٲ鵽ijÖÖJava¼¼ÇɵÄÓ÷¨¼°Ê¾Àý´úÂë, ÕâÊÇÒ»¸ö²»´íµÄÈ¥´¦.
2.[http://www.onjava.com] – O’ReillyµÄJavaÍøÕ¾. ÿÖܶ¼ÓÐÐÂÎÄÕÂ.
3.[http://java.sun.com] – ¹Ù·½µÄJava¿ª·¢ÕßÍøÕ ......
Éè¼ÆÒ»¸öCircleÀ࣬ÆäÊôÐÔΪԵ㣨ÀàÐÍΪÀàMyPoint£©ºÍ°ë¾¶£¬²¢Îª´ËÀà±àдÒÔÏÂÈý¸ö·½·¨£º
Ò»¡¢¼ÆËãÔ²µÄÃæ»ýµÄcalArea£¨£©·½·¨£»
¶þ¡¢¼ÆËãÖܳ¤µÄcalLength£¨£©·½·¨£»
Èý¡¢boolean inCircle£¨MyPoint mp£©·½·¨£¬¹¦ÄÜÊDzâÊÔ×÷Ϊ²ÎÊýµÄij¸öµãÊÇ·ñÔÚµ±Ç°¶ÔÏóÔ²ÄÚ£¨Ô²ÄÚ£¬°üÀ¨Ô²ÉÏ·µ»Øtrue£¬ÔÚÔ²Íâ·µ»Øfalse£©¡£
³ÌÐò£º
clas ......