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

Java Semaphore

package test;
/**
*
* @author openpk
*/
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
public class Main {
public static void main(String[] args) {
// Ï̳߳Ø
ExecutorService exec = Executors.newCachedThreadPool();
// Ö»ÄÜ5¸öÏß³Ìͬʱ·ÃÎÊ
final Semaphore semp = new Semaphore(1);
// Ä£Äâ20¸ö¿Í»§¶Ë·ÃÎÊ
for (int index = 0; index < 10; index++) {
final int NO = index;
Runnable run = new Runnable() {
public void run() {
try {
// »ñÈ¡Ðí¿É
semp.acquire();
System.out.println("Accessing: " + NO);
for(int i=0;i<400;i++)
System.out.print("Accessing: " + NO+" "+i);
System.out.println("");
Thread.sleep((long) (Math.random() * 10000));
// ·ÃÎÊÍêºó£¬ÊÍ·Å
semp.release();
} catch (InterruptedException e) {
}
}
};
exec.execute(run);
}
exec.shutdown();
}
}
// Í˳öÏ̳߳Ø


Ïà¹ØÎĵµ£º

ÓйØjavaÖеÄÒýÓÃÎÊÌâ

Ê×ÏÈ£¬java¶Ô¶ÔÏóºÍ»ù±¾ÀàÐ͵Ĵ¦ÀíÊDz»Ò»ÑùµÄ£¬ºÍCÓïÑÔÒ»Ñù£¬µ±°ÑJavaµÄ»ù±¾Êý¾ÝÀàÐÍ£¨Èçint£¬char£¬doubleµÈ£©×÷ΪÈë¿Ú²ÎÊý´«¸øº¯ÊýÌåµÄʱºò£¬´«ÈëµÄ²ÎÊýÔÚº¯ÊýÌåÄÚ²¿±ä³ÉÁ˾ֲ¿±äÁ¿£¬Õâ¸ö¾Ö²¿±äÁ¿ÊÇÊäÈë²ÎÊýµÄÒ»¸ö¿½±´£¬ËùÓеĺ¯ÊýÌåÄÚ²¿µÄ²Ù×÷¶¼ÊÇÕë¶ÔÕâ¸ö¿½±´µÄ²Ù×÷£¬º¯ÊýÖ´ÐнáÊøºó£¬Õâ¸ö¾Ö²¿±äÁ¿Ò²¾ÍÍê³ÉÁËËüµÄʹÃü£¬ ......

Java¶àÏ̱߳à³Ì»·¾³Öе¥ÀýģʽµÄʵÏÖ

Abstract
        
ÔÚ¿ª·¢ÖУ¬Èç¹ûij¸öʵÀýµÄ´´½¨ÐèÒªÏûºÄºÜ¶àϵͳ×ÊÔ´£¬ÄÇôÎÒÃÇͨ³£»áʹÓöèÐÔ¼ÓÔØ»úÖÆ£¬Ò²¾ÍÊÇ˵ֻÓе±Ê¹Óõ½Õâ¸öʵÀýµÄʱºò²Å»á´´½¨Õâ¸öʵÀý£¬Õâ¸öºÃ´¦ÔÚ
µ¥ÀýģʽÖеõ½Á˹㷺ӦÓá£Õâ¸ö»úÖÆÔÚsingle-threaded»·¾³ÏµÄʵÏַdz£¼òµ¥£¬È»¶øÔÚmulti-threaded» ......

java ·¢ËÍÓʼþʵÀý

package com.sj.main;
public class Snippet {
public static void main(String[] args){
//Õâ¸öÀàÖ÷ÒªÊÇÉèÖÃÓʼþ
MailSenderInfo mailInfo = new MailSenderInfo();
String biaoti ="ÎÒÊÇËÕ½¨£¬ÕâÊÇÎҵIJâÊÔÓʼþ";
String neirong = "ÎÒÊÇËÕ½¨ÒÔÏÂÊÇÎҵIJâÊÔÓʼþ£¬»¶Ó­´ó¼Ò½ ......

Java³£ÓÃÊõÓï½âÊÍ

PO VO BO DTO POJO DAOÃǵĸÅÄî
J2EE¿ª·¢ÖдóÁ¿µÄרҵËõÂÔÓïºÜÊÇÈÃÈËÃÔ»ó£¬ÓÈÆäÊǸúһЩ¸ßÊÖÌÖÂÛÎÊÌâµÄʱºò£¬Èý·ÖÖӾͱ»È˼ÒÂú¿ÚµÄרҵÊõÓïÅçÔÎÁË£¬PO VO BO DTO POJO DAO£¬Ò»´ó¶ÑµÄ¾ÍÀ´ÁË£¨Ìý¹ýÀÏÂÞ¶ÔÕâÖÖÏÖÏóµÄÅúÅеÄÅóÓÑ»á»áÐÄһЦ£©¡£
    Ê×ÏÈÉùÃ÷żҲ²»ÊÇʲô¸ßÊÖ£¬ÒÔÏÂ×ܽᶼÊÇ×Ô¼ºµÄÌå»á¡£²»¶ÔÖ®´ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ