JavaỊ̈߳ºÏ̵߳Äͬ²½ ͬ²½·½·¨
JavaỊ̈߳ºÏ̵߳Äͬ²½-ͬ²½·½·¨
Ï̵߳Äͬ²½ÊDZ£Ö¤¶àḬ̈߳²È«·ÃÎʾºÕù×ÊÔ´µÄÒ»ÖÖÊֶΡ£
Ï̵߳Äͬ²½ÊÇJava¶àÏ̱߳à³ÌµÄÄѵ㣬ÍùÍù¿ª·¢Õ߸㲻Çå³þʲôÊǾºÕù×ÊÔ´¡¢Ê²Ã´Ê±ºòÐèÒª¿¼ÂÇͬ²½£¬Ôõôͬ²½µÈµÈÎÊÌ⣬µ±È»£¬ÕâЩÎÊÌâûÓкÜÃ÷È·µÄ´ð°¸£¬µ«ÓÐЩÔÔòÎÊÌâÐèÒª¿¼ÂÇ£¬ÊÇ·ñÓоºÕù×ÊÔ´±»Í¬Ê±¸Ä¶¯µÄÎÊÌ⣿
ÔÚ±¾ÎÄ֮ǰ£¬Çë²ÎÔÄ¡¶JavaỊ̈߳ºÏ̵߳Äͬ²½ÓëËø¡·£¬±¾ÎÄÊÇÔÚ´Ë»ù´¡ÉÏËùдµÄ¡£
¶ÔÓÚͬ²½£¬ÔÚ¾ßÌåµÄJava´úÂëÖÐÐèÒªÍê³ÉÒ»ÏÂÁ½¸ö²Ù×÷£º
°Ñ¾ºÕù·ÃÎʵÄ×ÊÔ´±êʶΪprivate£»
ͬ²½ÄÄЩÐ޸ıäÁ¿µÄ´úÂ룬ʹÓÃsynchronized¹Ø¼ü×Öͬ²½·½·¨»ò´úÂë¡£
µ±È»Õâ²»ÊÇΨһ¿ØÖƲ¢·¢°²È«µÄ;¾¶¡£
synchronized¹Ø¼ü×ÖʹÓÃ˵Ã÷
synchronizedÖ»Äܱê¼Ç·Ç³éÏóµÄ·½·¨£¬²»Äܱêʶ³ÉÔ±±äÁ¿¡£
ΪÁËÑÝʾͬ²½·½·¨µÄʹÓ㬹¹½¨ÁËÒ»¸öÐÅÓÿ¨ÕË»§£¬Æð³õÐÅÓöîΪ100w£¬È»ºóÄ£Äâ͸֧¡¢´æ¿îµÈ¶à¸ö²Ù×÷¡£ÏÔÈ»ÒøÐÐÕË»§User¶ÔÏóÊǸö¾ºÕù×ÊÔ´£¬¶ø¶à¸ö²¢·¢²Ù×÷µÄÊÇÕË»§·½·¨oper(int x)£¬µ±È»Ó¦¸ÃÔÚ´Ë·½·¨ÉϼÓÉÏͬ²½£¬²¢½«ÕË»§µÄÓà¶îÉèΪ˽ÓбäÁ¿£¬½ûÖ¹Ö±½Ó·ÃÎÊ¡£
/**
* JavaỊ̈߳ºÏ̵߳Äͬ²½
*
* @author leizhimin 2009-11-4 11:23:32
*/
public class Test {
public static void main(String[] args) {
User u = new User("ÕÅÈý", 100);
MyThread t1 = new MyThread("Ïß³ÌA", u, 20);
MyThread t2 = new MyThread("Ïß³ÌB", u, -60);
MyThread t3 = new MyThread("Ïß³ÌC", u, -80);
MyThread t4 = new MyThread("Ïß³ÌD", u, -30);
MyThread t5 = new MyThread("Ïß³ÌE", u, 32);
&nbs
Ïà¹ØÎĵµ£º
×÷ΪJava³ÌÐòÔ±À´Ëµ£¬×îÍ´¿àµÄÊÂÇéĪ¹ýÓÚ¿ÉÒÔÑ¡ÔñµÄ·¶Î§Ì«¹ã£¬¿ÉÒÔ¶ÁµÄÊéÌ«¶à£¬ÍùÍùÈÝÒ×ÎÞËùÊÊ´Ó¡£ÎÒÏë¾ÍÎÒ×Ô¼º¶Á¹ýµÄ¼¼ÊõÊé¼®ÖÐÌôÑ¡³öÀ´Ò»Ð©£¬°´ÕÕѧϰµÄÏȺó˳Ðò£¬ÍƼö¸ø´ó¼Ò£¬ÌرðÊÇÄÇЩÏë²»¶ÏÌá¸ß×Ô¼º¼¼ÊõˮƽµÄJava³ÌÐòÔ±ÃÇ¡£
¡¡¡¡Ò»¡¢Java±à³ÌÈëÃÅÀà
¡¡¡¡¶ÔÓÚûÓÐJava±à³Ì¾ÑéµÄJava³ÌÐòÔ±ÒªÈëÃÅ£¬Ëæ±ã¶ÁʲôÈëÃÅÊé ......
commons-digester.jar
Digester»ùÓÚ¹æÔòµÄXMLÎĵµ½âÎö,Ö÷ÒªÓÃÓÚXMLµ½Java¶ÔÏóµÄÓ³Éä.
commons-beanutils.jar
Ìṩ¶ÔJava ·´ÉäºÍ×ÔÊ¡APIµÄ°ü×°.
aspectjweaver.jar
ÓÃÓÚÔÚSpring 2.0Öм¯³ÉAspectJ AspectJ LTWÖ¯ÈëÆ÷
ognl.jar
OGNLÊÇObject-Graph Navigation LanguageµÄËõд£¬ËüÊÇÒ»ÖÖ¹¦ÄÜÇ¿´óµÄ±í´ïʽÓïÑÔ£¨E ......
java -verbose[:class|gc|jni] ÔÚÊä³öÉ豸ÉÏÏÔʾÐéÄâ»úÔËÐÐÐÅÏ¢¡£
1.java -verbose:class
ÔÚ³ÌÐòÔËÐеÄʱºò¾¿¾¹»áÓжàÉÙÀà±»¼ÓÔØÄØ£¬Ò»¸ö¼òµ¥³ÌÐò»á¼ÓÔØÉÏ°Ù¸öÀàµÄ£¡Äã¿ÉÒÔÓÃverbose:classÀ´¼àÊÓ£¬ÔÚÃüÁîÐÐÊäÈëjava -verbose:class XXX (XXXΪ³ÌÐòÃû)Äã»áÔÚ¿ØÖÆ̨¿´µ½¼ÓÔصÄÀàµÄÇé¿ö¡£
verboseºÍverbose:cla ......
JavaỊ̈߳ºÏ̵߳Äͬ²½ÓëËø
Ò»¡¢Í¬²½ÎÊÌâÌá³ö
Ï̵߳Äͬ²½ÊÇΪÁË·ÀÖ¹¶à¸öÏ̷߳ÃÎÊÒ»¸öÊý¾Ý¶ÔÏóʱ£¬¶ÔÊý¾ÝÔì³ÉµÄÆÆ»µ¡£
ÀýÈ磺Á½¸öÏß³ÌThreadA¡¢ThreadB¶¼²Ù×÷ͬһ¸ö¶ÔÏóFoo¶ÔÏ󣬲¢ÐÞ¸ÄFoo¶ÔÏóÉϵÄÊý¾Ý¡£
public class Foo {
private int x = 100;
......
JavaỊ̈߳ºÏ̵߳ĵ÷¶È-ÓÅÏȼ¶
ÓëÏß³ÌÐÝÃßÀàËÆ£¬Ï̵߳ÄÓÅÏȼ¶ÈÔÈ»ÎÞ·¨±£ÕÏÏ̵߳ÄÖ´ÐдÎÐò¡£Ö»²»¹ý£¬ÓÅÏȼ¶¸ßµÄÏ̻߳ñÈ¡CPU×ÊÔ´µÄ¸ÅÂʽϴó£¬ÓÅÏȼ¶µÍµÄ²¢·Çû»ú»áÖ´ÐС£
Ï̵߳ÄÓÅÏȼ¶ÓÃ1-10Ö®¼äµÄÕûÊý±íʾ£¬ÊýÖµÔ½´óÓÅÏȼ¶Ô½¸ß£¬Ä¬ÈϵÄÓÅÏȼ¶Îª5¡£
ÔÚÒ»¸öÏß³ÌÖпªÆôÁíÍâÒ»¸öÐÂỊ̈߳¬ÔòпªÏ̳߳ÆÎ ......