JavaỊ̈߳º²¢·¢Ð×÷ Éú²úÕßÏû·ÑÕßÄ£ÐÍ
JavaỊ̈߳º²¢·¢Ð×÷-Éú²úÕßÏû·ÑÕßÄ£ÐÍ
¶ÔÓÚ¶àÏ̳߳ÌÐòÀ´Ëµ£¬²»¹ÜÈκαà³ÌÓïÑÔ£¬Éú²úÕߺÍÏû·ÑÕßÄ£ÐͶ¼ÊÇ×î¾µäµÄ¡£¾ÍÏñѧϰÿһÃűà³ÌÓïÑÔÒ»Ñù£¬Hello World£¡¶¼ÊÇ×î¾µäµÄÀý×Ó¡£
ʵ¼ÊÉÏ£¬×¼È·ËµÓ¦¸ÃÊÇ“Éú²úÕß-Ïû·ÑÕß-²Ö´¢”Ä£ÐÍ£¬À뿪Á˲ִ¢£¬Éú²úÕßÏû·ÑÕßÄ£Ð;ÍÏÔµÃûÓÐ˵·þÁ¦ÁË¡£
¶ÔÓÚ´ËÄ£ÐÍ£¬Ó¦¸ÃÃ÷ȷһϼ¸µã£º
1¡¢Éú²úÕß½ö½öÔÚ²Ö´¢Î´ÂúʱºòÉú²ú£¬²ÖÂúÔòÍ£Ö¹Éú²ú¡£
2¡¢Ïû·ÑÕß½ö½öÔÚ²Ö´¢ÓвúƷʱºò²ÅÄÜÏû·Ñ£¬²Ö¿ÕÔòµÈ´ý¡£
3¡¢µ±Ïû·ÑÕß·¢ÏÖ²Ö´¢Ã»²úÆ·¿ÉÏû·Ñʱºò»á֪ͨÉú²úÕßÉú²ú¡£
4¡¢Éú²úÕßÔÚÉú²ú³ö¿ÉÏû·Ñ²úƷʱºò£¬Ó¦¸Ã֪ͨµÈ´ýµÄÏû·ÑÕßÈ¥Ïû·Ñ¡£
´ËÄ£Ðͽ«Òª½áºÏjava.lang.ObjectµÄwaitÓënotify¡¢notifyAll·½·¨À´ÊµÏÖÒÔÉϵÄÐèÇó¡£ÕâÊǷdz£ÖØÒªµÄ¡£
/**
* JavaỊ̈߳º²¢·¢Ð×÷-Éú²úÕßÏû·ÑÕßÄ£ÐÍ
*
* @author leizhimin 2009-11-4 14:54:36
*/
public class Test {
public static void main(String[] args) {
Godown godown = new Godown(30);
Consumer c1 = new Consumer(50, godown);
Consumer c2 = new Consumer(20, godown);
Consumer c3 = new Consumer(30, godown);
Producer p1 = new Producer(10, godown);
Producer p2 = new Producer(10, godown);
Producer p3 = new Producer(10, godown);
Producer p4 = new Producer(10, godown);
&n
Ïà¹ØÎĵµ£º
public class test1
{
public static void main(String[] args){
//== ÓëequalsµÄÇø±ð
//1.nullµÄ±È½Ï£ºÖ»ÄÜÓÃ==
System.out.println("1.nullµÄ±È½Ï£ºÖ»ÄÜÓÃ==");
Object o1=null,o2=null;
System.out.println(null==null&&o1==null& ......
JavaỊ̈߳ºÏß³Ì״̬µÄת»»
SCJP5ѧϰ±Ê¼Ç
Ò»¡¢Ïß³Ì״̬
Ï̵߳Ä״̬ת»»ÊÇÏ߳̿ØÖƵĻù´¡¡£Ïß³Ì״̬×ܵĿɷÖΪÎå´ó״̬£º·Ö±ðÊÇÉú¡¢ËÀ¡¢¿ÉÔËÐС¢ÔËÐС¢µÈ´ý/×èÈû¡£ÓÃÒ»¸öͼÀ´ÃèÊöÈçÏ£º
1¡¢ÐÂ״̬£ºÏ̶߳ÔÏóÒѾ´´½¨£¬»¹Ã»ÓÐÔÚÆäÉϵ÷ÓÃstart()·½·¨¡£
2¡¢¿ÉÔËÐÐ״̬£ºµ±Ïß³ÌÓÐ× ......
JavaỊ̈߳ºÏ̵߳Ľ»»¥
SCJP5ѧϰ±Ê¼Ç
Ï߳̽»»¥ÊDZȽϸ´ÔÓµÄÎÊÌ⣬SCJPÒªÇ󲻺ܻù´¡£º¸ø¶¨Ò»¸ö³¡¾°£¬±àд´úÂëÀ´Ç¡µ±Ê¹Óõȴý¡¢Í¨ÖªºÍ֪ͨËùÓÐÏ̡߳£
Ò»¡¢Ï߳̽»»¥µÄ»ù´¡ÖªÊ¶
SCJPËùÒªÇóµÄÏ߳̽»»¥ÖªÊ¶µãÐèÒª´Ójava.lang.ObjectµÄÀàµÄÈý¸ö·½·¨À´Ñ§Ï°£º
void notify()
......
JavaỊ̈߳ºÏ̵߳Äͬ²½-ͬ²½¿é
¶ÔÓÚͬ²½£¬³ýÁËͬ²½·½·¨Í⣬»¹¿ÉÒÔʹÓÃͬ²½´úÂë¿é£¬ÓÐʱºòͬ²½´úÂë¿é»á´øÀ´±Èͬ²½·½·¨¸üºÃµÄЧ¹û¡£
×·Æäͬ²½µÄ¸ù±¾µÄÄ¿µÄ£¬ÊÇ¿ØÖƾºÕù×ÊÔ´µÄÕýÈ·µÄ·ÃÎÊ£¬Òò´ËÖ»ÒªÔÚ·ÃÎʾºÕù×ÊÔ´µÄʱºò±£Ö¤Í¬Ò»Ê±¿ÌÖ»ÄÜÒ»¸öÏ̷߳ÃÎʼ´¿É£¬Òò´ËJavaÒýÈëÁËͬ²½´úÂë¿ìµÄ²ßÂÔ£¬ÒÔÌá¸ßÐÔÄÜ¡£
&nb ......