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

javaÏß³ÌËÀËøÀý×Ó

public class DealLockTest implements Runnable {
static String i = new String();
static String j = new String();
private String str = null;
public DealLockTest(String str) {
this.str = str;
}
public static void main(String[] args) {
new Thread(new DealLockTest("i")).start();
new Thread(new DealLockTest("j")).start();
}
public void run() {
if (str.equals("i")) {
synchronized (i) {
System.out.println(Thread.currentThread().getName()+":"+"i");
Thread.yield();
synchronized (j) {
System.out.println("i is over");
}
}
} else {
synchronized (j) {
System.out.println(Thread.currentThread().getName()+":"+"j");
Thread.yield();
synchronized (i) {
System.out.println("j is over");
}
}
}
}
}

Ï̺߳Îʱ·¢ÉúËÀËøÄØ?
×î¼òµ¥µÄÇé¿öÊǵ±1¸öÏ̻߳ñµÃÁË×ÊÔ´A,µ±ËüÔÙ»ñµÃ×ÊÔ´Bʱ,¾Í¿ÉÒÔÍê³ÉÈÎÎñ.¶øÔÚËü»ñµÃÁËAµÄʱºò
ÁíÒ»¸öÏ̻߳ñµÃÁË×ÊÔ´B,È¥ÇÀ×ÊÔ´A..´Ëʱ,¾Í·¢ÉúÁËËÀËø
Ç°Ìá(¹²Ïí×ÊÔ´(static),¼ÓËø(synchronized)).


Ïà¹ØÎĵµ£º

Java iText ¶¯Ì¬ Éú³É PDF Îĵµ ±í¸ñ ÖÐÎÄÎÊÌâ

import java.awt.Color;
import java.io.FileOutputStream;
import com.lowagie.text.Cell;
import com.lowagie.text.Chapter;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.Image;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lo ......

Javaʵѵ

 ÎÒÃÇÿ¸öѧÆÚÄ©¶¼»á½øÐн«½üÒ»¸öÔµÄʵѵ£¬Õâ´ÎJavaʵѵҲ¼´½«½áÊø£¬ÎÒÑ¡µÄ¿ÎÌâÊÇ“¸öÈËÍøÉÏÒøÐÐϵͳ”£¬ÔËÓÃÁËStruts£¬HibernateºÍSpring¿ò¼Ü£¬Í¨¹ýmvcÉè¼Æģʽ¡£»ù±¾ËùÓеŦÄܶ¼ÊµÏÖÁË£¬ÔÚʵѵÖÐÕæµÄѧµ½Á˺ܶà֪ʶ£¬Ö®¼äÒ²Óöµ½Á˺ܶàÎÊÌ⣬µ«¶¼Ò»Ò»µÃµ½½â¾ö¡£ÎÒ½øÒ»²½Á˽âÁËStrutsµÄÔËÐÐÔ­Àí£¬ÂíÉÏÃæÁÙ ......

javaÃæÊÔÌâ

JAVAÃæÊÔÌ⼯- -
»ù´¡ÖªÊ¶£º
1.C++»òJavaÖеÄÒì³£´¦Àí»úÖƵļòµ¥Ô­ÀíºÍÓ¦Óá£
µ±JAVA³ÌÐòÎ¥·´ÁËJAVAµÄÓïÒå¹æÔòʱ£¬JAVA
ÐéÄâ»ú¾Í»á½«·¢ÉúµÄ´íÎó±íʾΪһ¸öÒì³£¡£Î¥·´ÓïÒå¹æÔò°üÀ¨2ÖÖÇé¿ö¡£Ò»ÖÖÊÇJAVAÀà¿âÄÚÖõÄÓïÒå¼ì²é¡£ÀýÈçÊý×éϱêÔ½½ç,»áÒý·¢
IndexOutOfBoundsException;·ÃÎÊnullµÄ¶ÔÏóʱ»áÒý·¢NullPointerExcepti ......

Java¶àÏ̱߳à³ÌÖеÄSynchronized

Synchronized£¬¹ËÃû˼Ò壬´ú±í¶à¸öÏß³ÌÖ®¼äµÄͬ²½¡£ÄÇô£¬ÔÚjava±à³ÌÖÐÈçºÎʹÓÃËüÄØ£¿ ÎÒÃǼÙÉèÕâÑùÒ»¸öÇé¿ö£º¶ÔÓÚͬһ¸ö±äÁ¿synDemo£¬ÎÒÃÇ·Ö±ðÔÚ2¸ö²»Í¬µÄÏß³ÌÖе÷ÓÃsynDemo.synMethord1()ÓësynDemo.synMethord2()¡£ package com.cnblogs.gpcuster;
/**
*
* @author Aaron.Guo
*
*/
public class Tester { ......

Java Serializable£¨ÐòÁл¯£©µÄÀí½âºÍ×ܽá

1¡¢ÐòÁл¯ÊǸÉʲôµÄ£¿
       ¼òµ¥Ëµ¾ÍÊÇΪÁ˱£´æÔÚÄÚ´æÖеĸ÷ÖÖ¶ÔÏóµÄ״̬£¨Ò²¾ÍÊÇʵÀý±äÁ¿£¬²»ÊÇ·½·¨£©£¬²¢ÇÒ¿ÉÒ԰ѱ£´æµÄ¶ÔÏó״̬ÔÙ¶Á³öÀ´¡£ËäÈ»Äã¿ÉÒÔÓÃÄã×Ô¼ºµÄ¸÷ÖÖ¸÷ÑùµÄ·½·¨À´±£´æobject states£¬µ«ÊÇJava¸øÄãÌṩһÖÖÓ¦¸Ã±ÈÄã×Ô¼ººÃµÄ±£´æ¶ÔÏó״̬µÄ»úÖÆ£¬ÄǾÍÊÇÐòÁл¯¡£
2¡¢Ê²Ã´Çé¿öÏ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ