JavaỊ̈߳ºÐÂÌØÕ÷ ÐźÅÁ¿
JavaỊ̈߳ºÐÂÌØÕ÷-ÐźÅÁ¿
JavaµÄÐźÅÁ¿Êµ¼ÊÉÏÊÇÒ»¸ö¹¦ÄÜÍê±ÏµÄ¼ÆÊýÆ÷£¬¶Ô¿ØÖÆÒ»¶¨×ÊÔ´µÄÏû·ÑÓë»ØÊÕÓÐןÜÖØÒªµÄÒâÒ壬ÐźÅÁ¿³£³£ÓÃÓÚ¶àÏ̵߳ĴúÂëÖУ¬²¢Äܼà¿ØÓжàÉÙÊýÄ¿µÄÏ̵߳ȴý»ñÈ¡×ÊÔ´£¬²¢ÇÒͨ¹ýÐźÅÁ¿¿ÉÒÔµÃÖª¿ÉÓÃ×ÊÔ´µÄÊýÄ¿µÈµÈ£¬ÕâÀï×ÜÊÇÔÚÇ¿µ÷“ÊýÄ¿”¶þ×Ö£¬µ«²»ÄÜÖ¸³öÀ´ÓÐÄÄЩÔڵȴý£¬ÄÄЩ×ÊÔ´¿ÉÓá£
Òò´Ë£¬±¾ÈËÈÏΪ£¬Õâ¸öÐźÅÁ¿ÀàÈç¹ûÄÜ·µ»ØÊýÄ¿£¬»¹ÄÜÖªµÀÄÄЩ¶ÔÏóÔڵȴý£¬ÄÄЩ×ÊÔ´¿ÉʹÓ㬾ͷdz£ÍêÃÀÁË£¬½ö½öÄõ½ÕâЩ¸ÅÀ¨ÐÔµÄÊý×Ö£¬¶Ô¾«È·¿ØÖÆÒâÒå²»ÊǺܴó¡£Ä¿Ç°»¹Ã»Ïëµ½¸üºÃµÄÓ÷¨¡£
ÏÂÃæÊÇÒ»¸ö¼òµ¥Àý×Ó£º
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
/**
* JavaỊ̈߳ºÐÂÌØÕ÷-ÐźÅÁ¿
*
* @author leizhimin 2009-11-5 13:44:45
*/
public class Test {
public static void main(String[] args) {
MyPool myPool = new MyPool(20);
//´´½¨Ï̳߳Ø
ExecutorService threadPool = Executors.newFixedThreadPool(2);
MyThread t1 = new MyThread("ÈÎÎñA", myPool, 3);
MyThread t2 = new MyThread("ÈÎÎñB", myPool, 12);
MyThread t3 = new MyThread("ÈÎÎñC", myPool, 7);
//ÔÚÏ̳߳ØÖÐÖ´ÐÐÈÎÎñ
threadPool.execute(t1);
&nbs
Ïà¹ØÎĵµ£º
´ò¿ªeclipse£¬·¢ÏÖeclipseå´µôÁË£¬²¢ÇÒ³öÏÖÕâÑùµÄÌáʾ£º¹ØÓÚInitializing java tooling£¨1%£©...
ÖØÆôÁ˼¸´ÎÖ®ºó·¢ÏÖÎÊÌâÈÔÈ»´æÔÚ£¬Òò¶ø¿ñËÑÁËÒ»°Ñ£¬ÖÕÓÚÕÒµ½ÕýÈ·µÄ½â¾ö°ì·¨£¬ÈçÏ£º
ÕÒµ½eclipseĿ¼£¬±à¼eclipse.iniÎļþ£¬ÔÚ-vmargs²ÎÊý֮ǰÌí¼ÓÉÏÈçϲÎÊý£¨Ò»¶¨ÒªÏñÏÂÃæÕâÑùд³ÉÁ½ÐУ©£¬È»ºóÖØÆô¾ÍokÁË
-vm
C:\Progr ......
JavaỊ̈߳º¸ÅÄîÓëÔÀí
SCJP5ѧϰ±Ê¼Ç
Ò»¡¢²Ù×÷ϵͳÖÐÏ̺߳ͽø³ÌµÄ¸ÅÄî
ÏÖÔڵIJÙ×÷ϵͳÊǶàÈÎÎñ²Ù×÷ϵͳ¡£¶àÏß³ÌÊÇʵÏÖ¶àÈÎÎñµÄÒ»ÖÖ·½Ê½¡£
½ø³ÌÊÇÖ¸Ò»¸öÄÚ´æÖÐÔËÐеÄÓ¦ÓóÌÐò£¬Ã¿¸ö½ø³Ì¶¼ÓÐ×Ô¼º¶ÀÁ¢µÄÒ»¿éÄÚ´æ¿Õ¼ä£¬Ò»¸ö½ø³ÌÖпÉÒÔÆô¶¯¶à¸öÏ̡߳£±ÈÈçÔÚWindowsϵͳÖУ¬Ò»¸öÔËÐеÄexe¾ÍÊÇÒ»¸ö½ø³Ì¡£
&nb ......
JavaỊ̈߳ºÏß³Ì״̬µÄת»»
SCJP5ѧϰ±Ê¼Ç
Ò»¡¢Ïß³Ì״̬
Ï̵߳Ä״̬ת»»ÊÇÏ߳̿ØÖƵĻù´¡¡£Ïß³Ì״̬×ܵĿɷÖΪÎå´ó״̬£º·Ö±ðÊÇÉú¡¢ËÀ¡¢¿ÉÔËÐС¢ÔËÐС¢µÈ´ý/×èÈû¡£ÓÃÒ»¸öͼÀ´ÃèÊöÈçÏ£º
1¡¢ÐÂ״̬£ºÏ̶߳ÔÏóÒѾ´´½¨£¬»¹Ã»ÓÐÔÚÆäÉϵ÷ÓÃstart()·½·¨¡£
2¡¢¿ÉÔËÐÐ״̬£ºµ±Ïß³ÌÓÐ× ......
JavaỊ̈߳ºÏ̵߳ĵ÷¶È-Èò½
Ï̵߳ÄÈò½º¬Òå¾ÍÊÇʹµ±Ç°ÔËÐÐ×ÅÏß³ÌÈóöCPU×ÊÔ´£¬µ«ÊÇÈ»¸ø˲»ÖªµÀ£¬½ö½öÊÇÈóö£¬Ïß³Ì״̬»Øµ½¿ÉÔËÐÐ״̬¡£
Ï̵߳ÄÈò½Ê¹ÓÃThread.yield()·½·¨£¬yield() Ϊ¾²Ì¬·½·¨£¬¹¦ÄÜÊÇÔÝÍ£µ±Ç°ÕýÔÚÖ´ÐеÄÏ̶߳ÔÏ󣬲¢Ö´ÐÐÆäËûÏ̡߳£
/**
* JavaỊ̈߳ºÏ̵߳ĵ÷¶È-Èò½
*
......
JavaỊ̈߳ºÏ̵߳Äͬ²½-ͬ²½¿é
¶ÔÓÚͬ²½£¬³ýÁËͬ²½·½·¨Í⣬»¹¿ÉÒÔʹÓÃͬ²½´úÂë¿é£¬ÓÐʱºòͬ²½´úÂë¿é»á´øÀ´±Èͬ²½·½·¨¸üºÃµÄЧ¹û¡£
×·Æäͬ²½µÄ¸ù±¾µÄÄ¿µÄ£¬ÊÇ¿ØÖƾºÕù×ÊÔ´µÄÕýÈ·µÄ·ÃÎÊ£¬Òò´ËÖ»ÒªÔÚ·ÃÎʾºÕù×ÊÔ´µÄʱºò±£Ö¤Í¬Ò»Ê±¿ÌÖ»ÄÜÒ»¸öÏ̷߳ÃÎʼ´¿É£¬Òò´ËJavaÒýÈëÁËͬ²½´úÂë¿ìµÄ²ßÂÔ£¬ÒÔÌá¸ßÐÔÄÜ¡£
&nb ......