Java СÀý×Ó£ºÏß³Ìͬ²½Àý×Ó£ºÈý¸öѧÉúÈ¡Ë®
Èý¸öѧÉúµ½Ò»¸öË®ÁúÍ·ÏÂÅŶÓÈ¡Ë®£¬ÈýÈ˶¼È¡ÍêË®ºóÒ»ÆðÀ뿪¡£
ÕâÀïÉæ¼°µ½ÈçºÎÅжÏÈý¸öÈ˶¼È¡ÍêË®¡£Èç¹ûÓÃÆÕͨµÄ¾²Ì¬³ÉÔ±£¬ÊƱػáÒªÓÃÎÞÏÞÑ»·À´µÈ´ý¡£¸üºÃµÄ°ì·¨ÊÇÓà wait-notify »úÖÆ¡£Ç°Á½¸öѧÉúÈ¡ÍêË®ºó¶¼ wait£¬×îºóÒ»¸öѧÉúÈ¡ÍêË®ºó notify£¬ÕâÑù¾ÍÄÜÒ»ÆðÀ뿪ÁË¡£ÏÂÃæÊÇ´úÂëʾÀý£º
/**
* Èý¸öѧÉúÅŶÓÈ¡Ë®£¬È¡ÍêºóÒ»ÆðÀ뿪
*
* @author yiding.he
*/
public class SyncDemo_FetchingWater {
private static final ValueLock water = new ValueLock();
public static void main(String[] args) {
String[] student_names = {"¼×", "ÒÒ", "±û"};
for (String student_name : student_names) {
new Student(student_name).start();
}
}
// ѧÉú
private static class Student extends Thread {
private String name;
private Student(String name) {
this.name = name;
}
@Override
public void run() {
try {
synchronized (water) {
Thread.sleep(1000);
System.out.println("ѧÉú" + name + "È¡ÍêÁËË®¡£");
water.value++;
if (water.value == 3) {
System.out.println("Èý¸öÈ˶¼È¡ÍêÁËË®¡£");
water.notifyAll(); // Ö»ÒªÖ´ÐÐÁËÕâ¸ö£¬Ñ§ÉúÃǶ¼»áÀ뿪¡£
} else {
water.wait(); // ͬʱÊÍ·ÅÁËËø£¬ÏÂÒ»¸öÏ߳̽øÈë
}
}
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("ѧÉú" + name + "À뿪ÁË¡£");
}
}
// ´øÖµµÄËø
private static class ValueLock {
public int value;
}
}
¸Ðл bendanlzh µÄÖ¸µã£¡
Ïà¹ØÎĵµ£º
Ò»¡¢JAVA¡£ÒªÏë³ÉΪJAVA£¨¸ß¼¶£©¹¤³Ìʦ¿Ï¶¨ÒªÑ§Ï°JAVA¡£Ò»°ãµÄ³ÌÐòÔ±»òÐíÖ»ÐèÖªµÀһЩJAVAµÄÓï·¨½á¹¹¾Í¿ÉÒÔÓ¦¸¶ÁË¡£µ«Òª³ÉΪJAVA£¨¸ß¼¶£©¹¤³Ìʦ£¬ÄúÒª¶ÔJAVA×ö±È½ÏÉîÈëµÄÑо¿¡£ÄúÓ¦¸Ã¶àÑо¿Ò»ÏÂJDBC¡¢IO°ü¡¢Util°ü¡¢Text°ü¡¢JMS¡¢EJB¡¢RMI¡¢Ï̡߳£Èç¹û¿ÉÄÜ£¬Ï£ÍûÄú¶ÔJAVAµÄËùÓаü¶¼ä¯ÀÀһϣ¬ÖªµÀ´ó¸ÅµÄAPI£¬ÕâÑùÄú¾Í·¢ÏÖÆä ......
JAVA Ìåϵ¼°Æä±à³ÌµÄ¹ý³Ì
°¥£¬±ÏÒµÁËÒ²Ò»¶Îʱ¼äÁË£¬Ö»ÖªµÀÌìÌì³´úÂ룬 JAVA µÄ»ù´¡ÖªÊ¶»ù±¾ÊÇÍüµôÁË£¬¼ÓÉÏÒÔǰһֱûÓÐϵͳµØѧϰ¹ý£¬¸Ð¾õ¿ìÒª·ÏÁË¡£»¹ÊǺúþ²ÏÂÐÄÀ´Ñ§Ñ§»ù´¡°É¡£²»ÄÜÌìÌ쿼³´úÂë¹ýÈÕ×Ó°¡¡£¡£¡£¡££¨ÏÂÎÄ´ó¶àÀ´×Կα¾ÒÔ¼°Ò»Ð©¼¼ÊõÊÓƵÉϵÄÄÚÈÝ£¬»ù±¾Àí½âÁËһЩÁË£¬Ê£ÏµÄÓÉÒÔºóµÄѧϰÂýÂýÔ ......
ÔÚ±à³ÌµÄʱºò£¬¾³£Óöµ½ÒªÅжÏÒ»¸ö×Ö·û´®ÖеÄ×Ö·ûÊÇ·ñÊÇÊý×Ö(0-9)
ÏÂÃæÎÒ¸ø´ó¼Ò½éÉܼ¸ÖÖʵÏÖ·½·¨
1.ʹÓÃCharacter.isDigit(char)ÅжÏ
String str = "123abc";
if (!"".equals(str)) {
char num[] = str.toCharArray();//°Ñ×Ö·û´®×ª»»Îª×Ö·ûÊý×é
StringBuffer title = new StringBuffer();//ʹÓÃS ......
ÊÖ¶¯½¨±í£º
CREATE TABLE `excel` (
`id` int(11) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL,
`passwd` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gb2312; ×¢ÒâÊÇgb2312
È»ºóÔÚÁ¬½ÓÊý¾Ý¿âʱ¼ÓÉÏ:
useUnicode=true&characterEncoding=gb2312.
¾ÍokÀ²£¡ ......