JavaỊ̈߳ºÐÂÌØÕ÷ Ëø£¨ÉÏ£©
JavaỊ̈߳ºÐÂÌØÕ÷-Ëø£¨ÉÏ£©
ÔÚJava5ÖУ¬×¨ÃÅÌṩÁËËø¶ÔÏó£¬ÀûÓÃËø¿ÉÒÔ·½±ãµÄʵÏÖ×ÊÔ´µÄ·âËø£¬ÓÃÀ´¿ØÖƶԾºÕù×ÊÔ´²¢·¢·ÃÎʵĿØÖÆ£¬ÕâЩÄÚÈÝÖ÷Òª¼¯ÖÐÔÚjava.util.concurrent.locks °üÏÂÃ棬ÀïÃæÓÐÈý¸öÖØÒªµÄ½Ó¿ÚCondition¡¢Lock¡¢ReadWriteLock¡£
Condition
Condition ½« Object ¼àÊÓÆ÷·½·¨£¨wait¡¢notify ºÍ notifyAll£©·Ö½â³É½ØÈ»²»Í¬µÄ¶ÔÏó£¬ÒÔ±ãͨ¹ý½«ÕâЩ¶ÔÏóÓëÈÎÒâ Lock ʵÏÖ×éºÏʹÓã¬ÎªÃ¿¸ö¶ÔÏóÌṩ¶à¸öµÈ´ý set £¨wait-set£©¡£
Lock
Lock ʵÏÖÌṩÁ˱ÈʹÓà synchronized ·½·¨ºÍÓï¾ä¿É»ñµÃµÄ¸ü¹ã·ºµÄËø¶¨²Ù×÷¡£
ReadWriteLock
ReadWriteLock ά»¤ÁËÒ»¶ÔÏà¹ØµÄËø¶¨£¬Ò»¸öÓÃÓÚÖ»¶Á²Ù×÷£¬ÁíÒ»¸öÓÃÓÚдÈë²Ù×÷¡£
ÓйØËøµÄ½éÉÜ,APIÎĵµ½â˵ºÜ¶à£¬¿´µÃºÜ·³£¬»¹ÊÇ¿´¸öÀý×ÓÔÙ¿´Îĵµ±È½ÏÈÝÒ×Àí½â¡£
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* JavaỊ̈߳ºËø
*
* @author leizhimin 2009-11-5 10:57:29
*/
public class Test {
public static void main(String[] args) {
//´´½¨²¢·¢·ÃÎʵÄÕË»§
MyCount myCount = new MyCount("95599200901215522", 10000);
//´´½¨Ò»¸öËø¶ÔÏó
Lock lock = new ReentrantLock();
//´´½¨Ò»¸öÏ̳߳Ø
ExecutorService pool = Executors.newCachedThreadPool();
//´´½¨Ò»Ð©²¢·¢·ÃÎÊÓû§£¬Ò»¸öÐÅÓÿ¨£¬´æµÄ´æ£¬È¡µÄÈ¡£¬ºÃÈÈÄÖ°¡
Ïà¹ØÎĵµ£º
½ñÌì°ÑÒÔǰдµÄjava´úÂëÄóöÀ´£¬·¢ÏÖ³öÁ˺öà´íÎó¡£µ÷ÁË°ëÌ죬·¢ÏÖÊÇ°æ±¾µÄÎÊÌ⣬ÓôÃÆ£¡
¿ÉÄÜ֮ǰÎÒд´úÂëµÄʱºòÓõÄÊÇJDK1.5£¬½ñÌì´ÓÍøÉÏÏÂÔØJDK1.6£¬Ã»³É¹¦¡£¾Í²Ý²ÝÏÂÔØÁËJDK1.5,½á¹û×ÜÊÇÌáʾ“could not find the main class. program will exit”¡£ÎҾ͵½
window-¡·preference-¡·java-¡·compiler°Ñµ±Ç°µÄ°æ ......
JavaỊ̈߳ºÏß³Ì״̬µÄת»»
SCJP5ѧϰ±Ê¼Ç
Ò»¡¢Ïß³Ì״̬
Ï̵߳Ä״̬ת»»ÊÇÏ߳̿ØÖƵĻù´¡¡£Ïß³Ì״̬×ܵĿɷÖΪÎå´ó״̬£º·Ö±ðÊÇÉú¡¢ËÀ¡¢¿ÉÔËÐС¢ÔËÐС¢µÈ´ý/×èÈû¡£ÓÃÒ»¸öͼÀ´ÃèÊöÈçÏ£º
1¡¢ÐÂ״̬£ºÏ̶߳ÔÏóÒѾ´´½¨£¬»¹Ã»ÓÐÔÚÆäÉϵ÷ÓÃstart()·½·¨¡£
2¡¢¿ÉÔËÐÐ״̬£ºµ±Ïß³ÌÓÐ× ......
JavaỊ̈߳ºÏ̵߳ĵ÷¶È-ÐÝÃß
JavaÏ̵߳÷¶ÈÊÇJava¶àÏ̵߳ĺËÐÄ£¬Ö»ÓÐÁ¼ºÃµÄµ÷¶È£¬²ÅÄܳä·Ö·¢»ÓϵͳµÄÐÔÄÜ£¬Ìá¸ß³ÌÐòµÄÖ´ÐÐЧÂÊ¡£
ÕâÀïÒªÃ÷È·µÄÒ»µã£¬²»¹Ü³ÌÐòÔ±Ôõô±àдµ÷¶È£¬Ö»ÄÜ×î´óÏ޶ȵÄÓ°ÏìÏß³ÌÖ´ÐеĴÎÐò£¬¶ø²»ÄÜ×öµ½¾«×¼¿ØÖÆ¡£
Ïß³ÌÐÝÃßµÄÄ¿µÄÊÇʹÏß³ÌÈóöCPUµÄ×î¼òµ¥µÄ×ö·¨Ö®Ò»£¬Ïß³ÌÐÝÃß ......
JavaỊ̈߳ºÏ̵߳Äͬ²½-ͬ²½¿é
¶ÔÓÚͬ²½£¬³ýÁËͬ²½·½·¨Í⣬»¹¿ÉÒÔʹÓÃͬ²½´úÂë¿é£¬ÓÐʱºòͬ²½´úÂë¿é»á´øÀ´±Èͬ²½·½·¨¸üºÃµÄЧ¹û¡£
×·Æäͬ²½µÄ¸ù±¾µÄÄ¿µÄ£¬ÊÇ¿ØÖƾºÕù×ÊÔ´µÄÕýÈ·µÄ·ÃÎÊ£¬Òò´ËÖ»ÒªÔÚ·ÃÎʾºÕù×ÊÔ´µÄʱºò±£Ö¤Í¬Ò»Ê±¿ÌÖ»ÄÜÒ»¸öÏ̷߳ÃÎʼ´¿É£¬Òò´ËJavaÒýÈëÁËͬ²½´úÂë¿ìµÄ²ßÂÔ£¬ÒÔÌá¸ßÐÔÄÜ¡£
&nb ......