Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JavaỊ̈߳ºÏ̵߳Ľ»»¥

JavaỊ̈߳ºÏ̵߳Ľ»»¥
 
SCJP5ѧϰ±Ê¼Ç
 
Ï߳̽»»¥ÊDZȽϸ´ÔÓµÄÎÊÌ⣬SCJPÒªÇ󲻺ܻù´¡£º¸ø¶¨Ò»¸ö³¡¾°£¬±àд´úÂëÀ´Ç¡µ±Ê¹Óõȴý¡¢Í¨ÖªºÍ֪ͨËùÓÐÏ̡߳£
 
Ò»¡¢Ï߳̽»»¥µÄ»ù´¡ÖªÊ¶
 
SCJPËùÒªÇóµÄÏ߳̽»»¥ÖªÊ¶µãÐèÒª´Ójava.lang.ObjectµÄÀàµÄÈý¸ö·½·¨À´Ñ§Ï°£º
 
 void notify()
          »½ÐÑÔڴ˶ÔÏó¼àÊÓÆ÷ÉϵȴýµÄµ¥¸öÏ̡߳£
 void notifyAll()
          »½ÐÑÔڴ˶ÔÏó¼àÊÓÆ÷ÉϵȴýµÄËùÓÐÏ̡߳£
 void wait()
          µ¼Öµ±Ç°µÄÏ̵߳ȴý£¬Ö±µ½ÆäËûÏ̵߳÷Óô˶ÔÏóµÄ notify() ·½·¨»ò notifyAll() ·½·¨¡£
 
µ±È»£¬wait()»¹ÓÐÁíÍâÁ½¸öÖØÔØ·½·¨£º
 void wait(long timeout)
          µ¼Öµ±Ç°µÄÏ̵߳ȴý£¬Ö±µ½ÆäËûÏ̵߳÷Óô˶ÔÏóµÄ notify() ·½·¨»ò notifyAll() ·½·¨£¬»òÕß³¬¹ýÖ¸¶¨µÄʱ¼äÁ¿¡£
 void wait(long timeout, int nanos)
          µ¼Öµ±Ç°µÄÏ̵߳ȴý£¬Ö±µ½ÆäËûÏ̵߳÷Óô˶ÔÏóµÄ notify() ·½·¨»ò notifyAll() ·½·¨£¬»òÕßÆäËûij¸öÏß³ÌÖжϵ±Ç°Ị̈߳¬»òÕßÒѳ¬¹ýij¸öʵ¼Êʱ¼äÁ¿¡£
 
ÒÔÉÏÕâЩ·½·¨ÊÇ°ïÖúÏ̴߳«µÝÏ̹߳ØÐĵÄʱ¼ä״̬¡£
 
¹ØÓڵȴý/֪ͨ£¬Òª¼ÇסµÄ¹Ø¼üµãÊÇ£º
±ØÐë´Óͬ²½»·¾³ÄÚµ÷ÓÃwait()¡¢notify()¡¢notifyAll()·½·¨¡£Ï̲߳»Äܵ÷ÓöÔÏóÉϵȴý»ò֪ͨµÄ·½·¨£¬³ý·ÇËüÓµÓÐÄǸö¶ÔÏóµÄËø¡£
wait()¡¢notify()¡¢notifyAll()¶¼ÊÇObjectµÄʵÀý·½·¨¡£Óëÿ¸ö¶ÔÏó¾ßÓÐËøÒ»Ñù£¬Ã¿¸ö¶ÔÏó¿ÉÒÔÓÐÒ»¸öÏß³ÌÁÐ±í£¬ËûÃǵȴýÀ´×Ô¸ÃÐźţ¨Í¨Öª£©¡£Ïß³Ìͨ¹ýÖ´ÐжÔÏóÉϵÄwait()·½·¨»ñµÃÕâ¸öµÈ´ýÁÐ±í¡£´ÓÄÇʱºòÆð£¬Ëü²»ÔÙÖ´ÐÐÈκÎÆäËûÖ¸Áֱµ½µ÷ÓöÔÏóµÄnotify()·½·¨ÎªÖ¹¡£Èç¹û¶à¸öÏß³ÌÔÚͬһ¸ö¶ÔÏóÉϵȴý£¬Ôò½«Ö»Ñ¡ÔñÒ»¸öỊ̈߳¨²»±£Ö¤ÒÔºÎÖÖ˳Ðò£©¼ÌÐøÖ´ÐС£Èç¹ûûÓÐÏ̵߳ȴý£¬Ôò²»²ÉÈ¡ÈκÎÌØÊâ²Ù×÷¡£
 
ÏÂÃæ¿´¸öÀý×Ó¾ÍÃ÷°×ÁË£º
/**
* ¼ÆËãÊä³öÆäËûÏß³ÌËø¼ÆËãµÄÊý¾Ý
*
* @author leizhimin 2008-9-15 13:20:38
*/
public class ThreadA {
    public static void main(String[] args) {
        ThreadB b = new


Ïà¹ØÎĵµ£º

JavaÓëC++

1¡¢Java²ÉÓÃUnicode×Ö·û¼¯£¬Ôö¼ÓÁ˶ԷÇÀ­¶¡ÓïϵµÄÖ§³Ö£¬Ò»¸öºº×Ö¿ÉÒÔÖ±½Ó×÷Ϊһ¸ö×Ö·û³£Á¿½øÐи³Öµ¶øÔÚC++ÖбØÐë×öΪ×Ö·û´®´¦Àí
  char chTemp = 'ÎÒ';
  System.out.println(chTemp);
Java×Ö·ûÊÇÒ»¸ö16ΪµÄÎÞ·ûºÅÕûÊý£¬C++ÖÐΪ8λ
2. Java±êʶ·û¿ÉÒÔÒÔÃÀÔª·û$¿ªÍ·£¬¿Éº¬ÓÐËùÓÐÊ®Áù½øÖÆÖµ´óÓÚ0xc0µ ......

javaÖÐ== ÓëequalsµÄÇø±ð

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Ị̈߳ºÏ̵߳Äͬ²½ÓëËø

JavaỊ̈߳ºÏ̵߳Äͬ²½ÓëËø
 
 
 
Ò»¡¢Í¬²½ÎÊÌâÌá³ö
 
Ï̵߳Äͬ²½ÊÇΪÁË·ÀÖ¹¶à¸öÏ̷߳ÃÎÊÒ»¸öÊý¾Ý¶ÔÏóʱ£¬¶ÔÊý¾ÝÔì³ÉµÄÆÆ»µ¡£
ÀýÈ磺Á½¸öÏß³ÌThreadA¡¢ThreadB¶¼²Ù×÷ͬһ¸ö¶ÔÏóFoo¶ÔÏ󣬲¢ÐÞ¸ÄFoo¶ÔÏóÉϵÄÊý¾Ý¡£
 
public class Foo {
    private int x = 100;
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ