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

Java¶àÏß³Ì,Éú²úÕß,Ïû·ÑÕ߻عË.¼òµ¥µÄÒ»Ìõ½Ö°ü×ÓÆÌ!

Ò»Ìõ½Ö,Óкܶà¼Ò°ü×ÓÆÌ,°ü×ÓÆÌ,¿ªÕŵÄʱºò,¶¼ÒѾ­×öºÃÁË19¸ö°ü×Ó,°ü×ÓÄØ,ÊDZß×ö±ßÂô.×ö1¸ö°ü×Ó,ÊÇÌú¶¨µÄ800ms,¶øÂô³ö1¸ö°ü×Ó²»»á³¬¹ý1s(ÉúÒâºÃ).
 package book.thread;
import java.util.List;
import java.util.Vector;
/**
* °ü×ÓÆÌ
*
* @author Vicky
*
*/
public class WaitNotify2 {
static class Shop implements Runnable {
private boolean isRunning = false;
private String name;
/** ¼Ç¼½ñÌì×öµÄ×ܹ²µÄ°ü×Ó * */
private int count = 0;
/** ×ö°ü×ÓµÄÈÎÎñ * */
private Thread subThread1 = null;
/** Âô°ü×ÓµÄÈÎÎñ * */
private Thread subThread2 = null;
/** °ü×ÓÆÌÖеİü×Ó * */
private List<Integer> baozis = new Vector<Integer>();
public Shop(String name) {
super();
this.name = name;
initShop();
}
/**
* ³õʼ»¯°ü×ÓÆÌ
*/
private void initShop() {
for (int i = 1; i < 20; i++) {
baozis.add(count++);
}
}
/**
* ×ö°ü×Ó,ÿÃë×ö1¸ö°ü×Ó
*/
public void makeBaozi() {
subThread1 = new Thread() {
@Override
public void run() {
while (baozis.size() < 20 && isRunning) {
synchronized (baozis) {
try {
Thread.sleep(800); // 800ºÁÃë²ÅÄÜ×ö1¸ö°ü×Ó
System.out.println("°ü×ÓÆÌ>> " + name + " <<¿ªÊ¼\"×ö\"µÚ[" + ++count + "]¸ö°ü×Ó!");
baozis.add(count);
if (baozis.size() >= 20) {
System.out.println("°ü×ÓÆÌ>> " + name + " <<°ü×ÓÂúÁË,Í£Ö¹×ö°ü×Ó!");
baozis.wait();
} else {
baozis.notifyAll(); // ÓÖ×öÁË1¸ö°ü×Ó,ÓÖ¿ÉÒÔÂô°ü×ÓÁË
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
};
subThread1.start();
}
/**
* ³öÊÛ°ü×Ó,0.5ÃëÂô³öÒ»¸ö°ü×Ó
*/
public void sellBaozi() {
subThread2 = new Thread() {
@Override
public void run() {
while (baozis.size() > 0 && isRunning) {
synchronized (baozis) {
try {
Thread.sleep((long) (M


Ïà¹ØÎĵµ£º

java ¼¯ºÏÀà

¼¯ºÏÀà˵Ã÷¼°Çø±ð
Collection
©ÀList
©¦©ÀLinkedList
©¦©ÀArrayList
©¦©¸Vector
©¦¡¡©¸Stack
©¸Set
Map
©ÀHashtable
©ÀHashMap
©¸WeakHashMap
Collection½Ó¿Ú
¡¡¡¡CollectionÊÇ×î»ù±¾µÄ¼¯ºÏ½Ó¿Ú£¬Ò»¸öCollection´ú±íÒ»×éObject£¬¼´CollectionµÄÔªËØ£¨Elements£©¡£Ò»Ð©
CollectionÔÊÐíÏàͬµÄÔªËØ¶øÁíһЩ²»ÐС ......

java ÃæÊÔ×ÊÁÏ£¨ÊÕ¼¯£©

1.¼òÊöÂß¼­²Ù×÷(&,|,^)ÓëÌõ¼þ²Ù×÷(&&,||)µÄÇø±ð¡£(15·Ö)
    a.Ìõ¼þ²Ù×÷Ö»ÄܲÙ×÷²¼¶ûÐ͵Ä,¶øÂß¼­²Ù×÷²»½ö¿ÉÒÔ²Ù×÷²¼¶ûÐÍ,¶øÇÒ¿ÉÒÔ²Ù×÷ÊýÖµÐÍ
    b.Âß¼­²Ù×÷²»»á²úÉú¶Ì·
2.ÏÂÃæ³ÌÐòÔËÐлᷢÉúʲô½á¹û?Èç¹ûÓдíÎó,ÈçºÎ¸ÄÕý? (15·Ö)
interface  A{
  int x = 0; ......

³ÉΪJava¸ßÊÖµÄ25¸öѧϰҪµã

1. ÄãÐèÒª¾«Í¨ÃæÏò¶ÔÏó·ÖÎöÓëÉè¼Æ(OOA/OOD)¡¢É漰ģʽ(GOF£¬J2EEDP)ÒÔ¼°×ÛºÏģʽ¡£ÄãÓ¦¸ÃÁ˽âUML£¬ÓÈÆäÊÇclass¡¢object¡¢interactionÒÔ¼°statediagrams¡£
2. ÄãÐèҪѧϰJavaÓïÑԵĻù´¡ÖªÊ¶ÒÔ¼°ËüµÄºËÐÄÀà¿â(collections¡¢serialization¡¢streams¡¢networking¡¢multithreading¡¢reflection¡¢event¡¢handling¡¢NIO¡¢localiza ......

Java´Ó¿ØÖÆÌ¨ÖжÁÈ¡Êý¾ÝÍêÈ«¹¥ÂÔ

0¡¡ÒýÑÔ
   
´Ó¿ØÖÆÌ¨ÖжÁÈ¡Êý¾ÝÊÇÒ»¸ö±È½Ï³£ÓõŦÄÜ£¬ÔÚ JDK 5.0 ÒÔǰµÄ°æ±¾ÖеÄʵÏÖÊDZȽϸ´Ôӵģ¬ÐèÒªÊÖ¹¤´¦ÀíϵͳµÄÊäÈëÁ÷¡£ÓÐÒâ˼µÄÊÇ£¬´Ó JDK 5.0 °æ±¾¿ªÊ¼£¬ÄÜ´Ó¿ØÖÆÌ¨ÖÐÊäÈëÊý¾ÝµÄ·½·¨Ã¿Ôö¼ÓÒ»¸ö°æ±¾ºÅ£¬¾ÍÓÐÒ»ÖÖÐÂÔöµÄ·½·¨£¬ÕâÒ²Ôö¼ÓÁËÑ¡ÔñµÄÖÖÀ࣬¿ÉÒÔÒÀ¾Ý²»Í¬µÄÒªÇóÀ´½øÐÐÑ¡Ôñ¡£ÏÂÃæÀ´¿´Ò»Ï ......

ajax ·¢ËÍxmlÎļþ£¬java½ÓÊÜxmlÎļþ²¢½âÎö

ºìÉ«×ÖÌåΪÖ÷Òª´úÂë
jspÒ³ÃæÖÐ
<script language="javascript">
function  updateDB(operate){
  var objDom=new ActiveXObject("msxml.DomDocument");
   var objRoot=objDom.createElement("All");
   objDom.appendChild(objRoot);
  
  var k=document.ge ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ