Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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Òì³£×ܽá

RuntimeExceptionlÀàÐ͵ÄÒì³£Ó¦Óñê×¼µÄ³ÌÐòÉè¼Æ¼¼ÇÉÀ´Ô¤·À£¬¶ø²»ÊÇʹÓÃtry-catch»úÖƲ¶»ñ¡£Òþº¬Òì³£°üº¬ErrorsºÍRuntimeException£¬¶ÔÓÚºóÕßÓÃifÓï¾ä·ÀÖ¹²úÉú¡£Èç·ÃÎÊ¿ÉÄÜδÕýÈ·³õʼ»¯ÒýÓñäÁ¿Ç°£¬Ïȼì²éÊÇ·ñÖ¸Ïò¿ÕÖµ£»·ÃÎÊÊý×éʱ£¬Ïȼì²éϱêÊÇ·ñÔ½½ç¡£
×Ô¶¨ÒåÒì³££º´´½¨Ò»¸ö¼Ì³ÐExceptionµÄÀà»òÆäËûÒÑ´æÔÚµÄ×ÓÀ࣬´´½¨Ò ......

java post get Á¬½ÓÍøÒ³

postºÍgetµÄÇø±ð£º
getÊÇͨ¹ýURLÏò·þÎñÆ÷µÝ½»Êý¾Ý£¬¼´Ìá½»µÄÏà¹ØÐÅÏ¢°üº¬ÔÚµØÖ·À¸µÄURLÖÐ
postÌá½»ºóµØÖ·À¸²»±ä
¿ÉÒÔͨ¹ýJava.net.URLEncoder½«ÖÐÎÄ×Ö·û±äΪ¿ÉÒÔ¼ÓÔÚURLÖÐÓÃÓÚ²éѯµÄ±àÂ룬ÏàÓ¦µÄ£¬Java.net.URLDecoderÓÃÓÚÏà¹ØµÄ½âÂë
Apache¿ªÔ´×éÖ¯ÖеÄhttpclient£¬ËüÁ¥ÊôÓÚJakartaµÄcommonsÏîÄ¿£¬×¨ÃÅÉè¼ÆÀ´¼ò»¯HTTP¿ ......

javaÈÕÆÚ

Date ---->String
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String date = sdf.fomat(new Date());

String ---->Date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = sdf.parse("2010-03-16");

ÈÕÆڱȽϴóС£¬Õâ¾ÍÓõ½ÁËDateÀàÖеÄbefore()ºÍafter()·½· ......

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

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