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

java¶ÁдËøʵÏÖ»úÖÆ

package thread.lock;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
 * @file_name ReadAndWriteLockDemo.java
 * @description ¶ÁдËøDEMO
 * @author ÕÅÃ÷ÁÁ
 * @date 2009.09.27
 */
public class ReadAndWriteLockDemo {
 ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
 // ¶ÁËø
 Lock rLock = rwLock.readLock();
 // дËø
 Lock wLock = rwLock.writeLock();
 // »õ¼Ü
 List<String> stock = new ArrayList<String>();
    //»¥³âËø
 ReentrantLock lock = new ReentrantLock();
 /**
  * ÉÌÆ·ÂòÂô
  * <br>
  * µ±ÉÌÆ·ÊýÁ¿Ð¡ÓÚ1ʱ£¬ÊͷŶÁËø²¢»ñȡдËø Éú²úÉÌÆ·ºó£¬
  * <br>
  * Ëø½µ¼¶ÔÚдËø±£»¤ÏÂÖØлñÈ¡¶ÁËø²¢Ïû·ÑÉÌÆ·
  */
 public void sell() {
//  lock.lock();
  try {
   rLock.lock();
   if (stock.size() <= 0) {
    rLock.unlock();
    wLock.lock();
    manufacture();
    rLock.lock();
    wLock.unlock();
   }
   consume();
   rLock.unlock();
  } finally {
//   lock.unlock();
  }
 }
 /**
  * Éú²úÉÌÆ·
  */
 private void manufacture() {
  stock.add("product");
 }
 /**
  * Ïû·ÑÉÌÆ·
  */
 private void consume() {
  System.err.println(stock.remove(0));
 }
 public static void main(String[] args) {
  final ReadAndWriteLockDemo rwDemo = new ReadAndWriteLockDemo();
  rwDemo.sell();
//  Thread t1 = new Thread("threa--1") {
//   public void run() {
//    rwDemo.sell(


Ïà¹ØÎĵµ£º

Java heep space£¨JavaÄÚ´æÒç³öÎÊÌ⣩

½ñÌìÓöµ½ÁËÕâ¸öÎÊÌâ ÁËºÇºÇ ½â¾öÁ˸ø´ó¼Ò·ÖÏíÏÈ£¬java.lang.OutOfMemoryError: Java heap space ÒýÆðÁËÎÒÉÏ´«³ö´í¡£ÎÒ½â¾ö°ì·¨¾ÍÊÇ¿´ÄãʹÓõÄtomcat·þÎñÆ÷°æ±¾ÊÇʲôÑùµÄ£¬Èç¹ûÄãµÄtomcat/binϱßÓÐtomcatw.exe ¾Í·½±ãÁË£¬Ö±½Ó¿ÉÊÓ»¯²Ù×÷ŶÏÂÏÂͼ
ÆäÖÐÉèÖóõʼÄÚ´æ³ØºÍ×î´óÄÚ´æ³Ø£¬ÉèÖÃÔ­ÔòÊǸù¾ÝÄãµÄÎïÀíÄÚ´æÀ´¶¨¡£
Èç¹û ......

ÈçºÎ°ÑJAVA³ÌÐò·â×°³ÉEXEÎļþ

 ¿ÉÒÔ°ÑÆÕͨµÄJava³ÌÐò×ö³ÉÕæÕýµÄexe,Ò²¾ÍÊǵ¥Ò»¸öexe¾Í¿ÉÒÔÔÚûÓа²×°JVMµÄ»úÆ÷ÉÏÔËÐС£ÕâÑùµÄ¹¤¾ß³£¼ûµÄÓÐJETºÍgcj.Ç°ÕßÊÇÊշѵģ¬¶øÇÒ×ö³öÀ´µÄexe»¹ÊÇÐèÒªÒ»¶Ñdll¡£ÍƼöʹÓÃgcj.ËûÓÐwindowsºÍLinux°æ£¬Ö±½ÓÏÂÔØzip°ü£¬²»ÐèÒª°²×°£¬ÀïÃæÓв»ÉÙÀý×Ó£¬Ò»Ð©buildµÄÅú´¦ÀíÎļþ¡£´ÓÔ­ÀíÀ´Ëµgcj×Ô¼ºÊµÏÖÁËJVM¹æ·¶£¬Ò²¾ÍÊÇÄ ......

Ò»¸öjava³ÌÐòÔ±µÄ³É³¤Àú³Ì(ºÜÔçµÄÎÄÕÂÁË)

ºÜ¶àÍøÓÑÎÊÎÒѧϰJavaÓÐûÓÐʲô½Ý¾¶,ÎÒ˵“ÎÞËû£¬Î¨ÊÖÊì¶û”¡£µ«ÊÇÎÒÈ´ºÜÔ¸Ò⽫×Ô¼ºÑ§Ï°µÄһЩ¾­Ñéд³öÀ´£¬ÒÔ±ãºóÀ´ÕßÉÙ×ßÍä·,°ïÖú±ðÈËÊÇ×î´óµÄ¿ìÀÖÂ
ÒªÏëѧºÃJava£¬Ê×ÏÈÒªÖªµÀJavaµÄ´óÖ·ÖÀà¡£ÎÒÃÇÖªµÀ£¬×Ô´ÓSunÍƳöJavaÒÔÀ´£¬¾ÍÁ¦Í¼Ê¹Ö®ÎÞËù²»°ü£¬ËùÒÔJava·¢Õ¹µ½ÏÖÔÚ£¬°´Ó¦ÓÃÀ´·ÖÖ÷Òª·ÖΪÈý´ó¿é£ºJ2SE,J2 ......

C#ÓëC++¡¢JAVAµÄÇø±ð


#(¶Á×ö "C sharp")ÊÇ΢Èí¹«Ë¾ÔÚÈ¥ÄêÁùÔ·¢²¼µÄÒ»ÖÖеıà³ÌÓïÑÔ,²¢¶¨ÓÚÔÚ΢ÈíÖ°Òµ¿ª·¢ÕßÂÛ̳(PDC)ÉϵÇ̨ÁÁÏà.C#ÊÇ΢Èí¹«Ë¾Ñо¿Ô±Anders HejlsbergµÄ×îгɹû.C#¿´ÆðÀ´ÓëJavaÓÐמªÈ˵ÄÏàËÆ;Ëü°üÀ¨ÁËÖîÈçµ¥Ò»¼Ì³Ð,½çÃæ,ÓëJava¼¸ºõͬÑùµÄÓï·¨,ºÍ±àÒë³ÉÖмä´úÂëÔÙÔËÐеĹý³Ì.µ«ÊÇC#ÓëJavaÓÐ×ÅÃ÷ÏԵIJ»Í¬,Ëü½è¼øÁËDelphiµÄÒ»¸ ......

javaÖÐÈçºÎÒÔwindows¼¯³É·½Ê½Á¬½ÓSQL Server

ÔÚ¡¶JDBC Driver For SQL2000/2005/2008
¡·Ò»ÎÄÖУ¬ÑûÔ½éÉÜÁËÈçºÎÏÂÔز¢Ê¹ÓÃjdbcÁ¬½ÓSQL Server,
½ñÌìÓÐÈËÎÊÆð£¬ÈçºÎÒÔwindows¼¯³É·½Ê½Á¬½ÓSQL Server,Õâ¸öÒÔÇ°ÕæûÊÔ¹ý¡£
ÓÚÊÇ£¬´ò¿ªnetBeans²âÊÔÁËһϣ¬´úÂëÈçÏ£º
/*
* To change this template, choose Tools | Templates
* and open the template in the edit ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ