JavaÃæÊÔÌ⣨8£©
123¡¢Éè¼Æ4¸öỊ̈߳¬ÆäÖÐÁ½¸öÏß³Ìÿ´Î¶ÔjÔö¼Ó1£¬ÁíÍâÁ½¸öÏ̶߳Ôjÿ´Î¼õÉÙ1¡£Ð´³ö³ÌÐò¡£
ÒÔϳÌÐòʹÓÃÄÚ²¿ÀàʵÏÖỊ̈߳¬¶ÔjÔö¼õµÄʱºòûÓп¼ÂÇ˳ÐòÎÊÌâ¡£
public class ThreadTest1{
private int j;
public static void main(String args[]){
ThreadTest1 tt=new ThreadTest1();
Inc inc=tt.new Inc();
Dec dec=tt.new Dec();
for(int i=0;i<2;i++){
Thread t=new Thread(inc);
t.start();
t=new Thread(dec);
t.start();
}
}
private synchronized void inc(){
j++;
System.out.println(Thread.currentThread().getName()+"-inc:"+j);
}
private synchronized void dec(){
j--;
System.out.println(Thread.currentThread().getName()+"-dec:"+j);
}
class Inc implements Runnable{
public void run(){
for(int i=0;i<100;i++){
inc();
}
}
}
class Dec implements Runnable{
public void run(){
for(int i=0;i<100;i++){
dec();
}
}
}
}
124¡¢JavaÓÐûÓÐgoto?
javaÖеı£Áô×Ö£¬ÏÖÔÚûÓÐÔÚjavaÖÐʹÓá£
125¡¢Æô¶¯Ò»¸öÏß³ÌÊÇÓÃrun()»¹ÊÇstart()?
¡¡¡¡Æô¶¯Ò»¸öÏß³ÌÊǵ÷ÓÃstart()·½·¨£¬Ê¹Ïß³ÌËù´ú±íµÄÐéÄâ´¦Àí»ú´¦ÓÚ¿ÉÔËÐÐ״̬£¬ÕâÒâζ×ÅËü¿ÉÒÔÓÉJVMµ÷¶È²¢Ö´ÐС£Õâ²¢²»Òâζ×ÅÏ߳̾ͻáÁ¢¼´ÔËÐС£run()·½·¨¿ÉÒÔ²úÉú±ØÐëÍ˳öµÄ±êÖ¾À´Í£Ö¹Ò»¸öÏ̡߳£
Ïà¹ØÎĵµ£º
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
×¢£º
½ÌʦµÄµãÆÀÒÔ´ÖÌå+ºìÉ«±ê³ö¡£
JavaÃæÏò¶ÔÏóÊÔÌâ·ÖÎö
˵Ã÷£º
£¨1£©¿¼ÊÔʱ¼äΪ2Сʱ¡£
£¨2£©³ý¼ò´ðÌâºÍ±à³ÌÌâÍ⣬ËùÓд𰸾ù¿ÉÖ±½ÓдÔÚÊÔ¾íÉÏ¡£
&nb ......
JNBridgeÌṩÁË¿çÔ½JavaÓë.NET´úÂëµÄ·Ö²¼Ê½ÊÂÎñÖ§³Ö
×÷Õß Jonathan Allen ÒëÕß ÕÅÁú ·¢²¼ÓÚ 2009Äê12ÔÂ28ÈÕ ÉÏÎç5ʱ5·Ö
ÉçÇø .NET, Java Ö÷Ìâ »¥²Ù×÷, ÊÂÎñ´¦Àí ±êÇ© JNBridge
ƾ½èJNBridge¼¼Êõ£¬JavaºÍ.NET´úÂëÎÞÐè½»²æ±àÒëÆ÷¾Í¿ÉÒÔʵÏÖ¶ÔÏó¹²Ïí¡£ËùÓÐJava´úÂëÔËÐÐÔÚJVMÉÏ£¬¶ø.NET´úÂëÔòÔËÐÐÔÚCLRÉÏ¡£Ôڸ÷½°¸Ï£¬JVM ......
Ôü×Ò»ØÊÕµÄã£ÂÛ
Ëùν“³ÉÒ²ÏôºÎ°ÜÏôºÎ”¡£JavaµÄÔü×Ò»ØÊÕȷȷʵʵ´øµ½Á˺ܶàºÃ´¦£¬Îª¿ª·¢´ø»ØÁË·½±ã¡£µ«ÊÇÔÚһЩ¸ßÐÔÄÜ¡¢¸ß²¢·¢µÄÇé¿öÏ£¬Ôü×Ò»ØÊÕÈ·±äΪÁËǯÖÆJavaʹÓõÄÆ¿¾±¡£µ±Ç°JDKµÄÔü×Ò»ØÊÕËã·¨£¬Ê¼ÖÕû·¨½â¾öÔü×Ò»ØÊÕʱµÄÔÝÍ£ÎÊÌ⣬ÓÉÓÚÕâ¸öÔÝÍ£ÑÏÖØÓ°ÏìÁ˳ÌÐòµÄºôӦʱ¼ä£¬´Ù³É¶ÂÈû»ò»ý¾Û¡£ÕâÒ²ÊǺóÐøJDK ......
20¡¢abstract classºÍinterfaceÓÐʲôÇø±ð?
¡¡¡¡ÉùÃ÷·½·¨µÄ´æÔÚ¶ø²»È¥ÊµÏÖËüµÄÀà±»½Ð×ö³éÏóÀࣨabstract class£©£¬ËüÓÃÓÚÒª´´½¨Ò»¸öÌåÏÖijЩ»ù±¾ÐÐΪµÄÀ࣬²¢Îª¸ÃÀàÉùÃ÷·½·¨£¬µ«²»ÄÜÔÚ¸ÃÀàÖÐʵÏÖ¸ÃÀàµÄÇé¿ö¡£²»ÄÜ´´½¨abstract ÀàµÄʵÀý¡£È»¶ø¿ÉÒÔ´´½¨Ò»¸ö±äÁ¿£¬ÆäÀàÐÍÊÇÒ»¸ö³éÏóÀ࣬²¢ÈÃËüÖ¸Ïò¾ßÌå×ÓÀàµÄÒ»¸öʵÀý¡£²»ÄÜÓг ......