Java ¶àÏ̱߳à³ÌÖ®Èý£ºsynchronized ¹Ø¼ü×ÖµÄʹÓÃ
Java ¶àÏ̱߳à³ÌÖ®Èý£ºsynchronized ¹Ø¼ü×ÖµÄʹÓÃ
´øÓÐ synchronized ¹Ø¼ü×ֵķ½·¨´ú±íÕâ¸ö·½·¨¼ÓËø¡£Ç¡µ±¶øÓÖÁé»îµØÔËÓà synchronized ¹Ø¼ü×Ö£¬ÊǶàÏ̱߳à³ÌµÄ±ØÐ޿Ρ£
¡¡¡¡1¡¢synchronized¹Ø¼ü×ÖµÄ×÷ÓÃÓòÓжþÖÖ£º
¡¡¡¡1£©ÊÇij¸ö¶ÔÏóʵÀýÄÚ£¬synchronized aMethod(){}¿ÉÒÔ·ÀÖ¹¶à¸öÏß³Ìͬʱ·ÃÎÊÕâ¸ö¶ÔÏóµÄsynchronized·½·¨£¨Èç¹ûÒ»¸ö¶ÔÏóÓжà¸ösynchronized·½·¨£¬Ö»ÒªÒ»¸öÏ̷߳ÃÎÊÁËÆäÖеÄÒ»¸ösynchronized·½·¨£¬ÆäËüÏ̲߳»ÄÜͬʱ·ÃÎÊÕâ¸ö¶ÔÏóÖÐÈκÎÒ»¸ösynchronized·½·¨£©¡£Õâʱ£¬²»Í¬µÄ¶ÔÏóʵÀýµÄ synchronized·½·¨ÊDz»Ïà¸ÉÈŵġ£Ò²¾ÍÊÇ˵£¬ÆäËüÏß³ÌÕÕÑù¿ÉÒÔͬʱ·ÃÎÊÏàͬÀàµÄÁíÒ»¸ö¶ÔÏóʵÀýÖеÄsynchronized·½·¨£»
¡¡¡¡2£©ÊÇij¸öÀàµÄ·¶Î§£¬synchronized static aStaticMethod(){}·ÀÖ¹¶à¸öÏß³Ìͬʱ·ÃÎÊÕâ¸öÀàÖеÄsynchronized static ·½·¨¡£Ëü¿ÉÒÔ¶ÔÀàµÄËùÓжÔÏóʵÀýÆð×÷Óá£
¡¡¡¡2¡¢³ýÁË·½·¨Ç°ÓÃsynchronized¹Ø¼ü×Ö£¬synchronized¹Ø¼ü×Ö»¹¿ÉÒÔÓÃÓÚ·½·¨ÖеÄij¸öÇø¿éÖУ¬±íʾֻ¶ÔÕâ¸öÇø¿éµÄ×ÊԴʵÐл¥³â·ÃÎÊ¡£Ó÷¨ÊÇ: synchronized(this){/*Çø¿é*/}£¬ËüµÄ×÷ÓÃÓòÊǵ±Ç°¶ÔÏó¡£
synchronized(this)ÓÃÓÚ¶¨ÒåÒ»¸öÁÙ½çÇø£¨¼´ÊÇ£ºÆäºóÃæ´óÀ¨»¡Ëù°üº¬µÄ²¿·Ö£©£¬ÒÔ±£Ö¤ÔÚ¶àÏß³ÌÏÂÖ»ÄÜÓÐÒ»¸öÏ߳̿ÉÒÔ½øÈëthis¶ÔÏóµÄÁÙ½çÇø¡£ Ò²¾ÍÊÇ˵synchronized(¶ÔÏó»òÕß±äÁ¿){}£¬±íʾÔÚ{}ÄÚµÄÕâ¶Î´úÂëÖУ¬¶Ô£¨¶ÔÏó»òÕß±äÁ¿£©ÖеĶÔÏó»òÕß±äÁ¿½øÐÐͬ²½´¦Àí£¬Ò²¾ÍÊÇ˵µ±·ÃÎÊÕâ¶Î´úÂëʱ£¬Ò»¸öÏ̶߳ԶÔÏó»òÕß±äÁ¿µÄ·ÃÎÊÍê³Éºó²ÅÄܹ»½»¸øÁíÍâÒ»¸öỊ̈߳¬¼´ÓÐÁËͬ²½Ëø¡£Ê¹Óà synchronized(¶ÔÏó»òÕß±äÁ¿)£¬¾ÍÊÇΪÁË·ÀÖ¹¶ÔÏó»òÕß±äÁ¿±»Í¬Ê±·ÃÎÊ£¬±ÜÃâ¶à¸öÏß³ÌÐ޸ĺͶÁÈ¡¶ÔÏó»òÕß±äÁ¿Í¬Ê±³öÏÖµÄʱºò£¬Ê¹ÓÃÕâ¸ö¶ÔÏó»òÕß±äÁ¿µÄµØ·½³öÏÖ´íÎóµÄÅжϣ¬Èç while(¶ÔÏó»òÕß±äÁ¿)¡£
¡¡¡¡3¡¢synchronized¹Ø¼ü×ÖÊDz»Äܼ̳еģ¬Ò²¾ÍÊÇ˵£¬»ùÀàµÄ·½·¨synchronized f(){} Ôڼ̳ÐÀàÖв¢²»×Ô¶¯ÊÇsynchronized f(){}£¬¶øÊDZä³ÉÁËf(){}¡£¼Ì³ÐÀàÐèÒªÄãÏÔʽµÄÖ¸¶¨ËüµÄij¸ö·½·¨Îªsynchronized·½·¨¡£
Ïà¹ØÎĵµ£º
½Ó¿ÚÖв»¿ÉÒÔ¶¨Òå¹¹Ôì·½·¨
½Ó¿ÚÖÐÖ»ÄÜÓÐ public static final µÄ±äÁ¿ ºÍ public abstract µÄ·½·¨£¬ÆäËü¶¼²»¿ÉÒÔ¡£
ÀýÈ磺
´úÂëÀïÊÇÕâÑùдµÄ
public interface B{
StringBuilder sb=null;
void fun();
& ......
http://www.gotapi.com/
ÓïÑÔ£ºÓ¢Óï
¼ò½é£ºHTML,CSS,XPATH,XSL,JAVASCRIPTµÈAPIµÄ²éѯÍøÕ¾¡£
http://www.w3schools.com/
ÓïÑÔ£ºÓ¢Óï
¼ò½é£ºW3CÖƶ¨µÄ±ê×¼ÖîÈçXML,HTML,XSLµÈµÈµÄÔÚÏßѧϰ½Ì³Ì¡£
http://www.xml.org.cn/
ÓïÑÔ£ºÖÐÎÄ
¼ò½é£º¿ÉÒÔ˵ÊÇXMLµÄÖйú¹Ù·½Íø°É¡£W3C ......
ʼþÔ´¸ºÔð²úÉúʼþ
ʼþÀࣺ¶¨ÒåʼþµÄÌØÕ÷£»
¼àÌýÆ÷½Ó¿Ú£º¶¨Òå¼àÌýÆ÷Ó¦¸ÃʵÏֵŦÄÜ£»
¼àÌýÆ÷£ºÊµÏÖ¼àÌýÆ÷½Ó¿Ú£¬¼àÌýʼþµÄ·¢Éú²¢×÷³öÏìÓ¦£»
ËùÓеÄʼþÀà±ØÐë¼Ì³ÐJavaʼþ»ùÀ࣬¼´java.util.EventObject£»EventObject(Object source)ÊÇEventObjectΨһµÄ¹¹Ôì·½·¨£¬ÕâÒâζ×ÅËùÓÐʼþ±ØÐëÔÚʵÀý»¯Ê±¾ÍÖ¸¶¨Ê¼þÔ´ ......
import java.net.URL;
import java.net.URLDecoder;
public class PathUtil
{
/**
* Get the env of windir, such as "C:\WINDOWS".
* @return the env of windir value.
*/
public static String getWindir(){
return System.getenv("windir");
}
......
ÎÊÌâÃèÊö
Exception in thread "main" java.lang.OutOfMemoryError:
Java heap space
½â¾ö·½°¸[ת]
Ò»Ö±¶¼ÖªµÀ¿ÉÒÔÉèÖÃjvm heap´óС£¬Ò»Ö±ÓÃeclipseд/µ÷ÊÔjava³ÌÐò¡£Ò»Ö±ÓÃÃüÁîÐÐor
console¼Ó²ÎÊýÅܳÌÐò¡£ÏÖÏó£ºÔÚeclipseµÄÅäÖÃÎļþeclipse.iniÖÐÉèÖÃ-vmargs -Xms500m
-Xmx1024m
£¬ÔÚeclipseÖ ......