JavaỊ̈߳ºÐÂÌØÕ÷ Ï̳߳Ø
JavaỊ̈߳ºÐÂÌØÕ÷-Ï̳߳Ø
SunÔÚJava5ÖУ¬¶ÔJavaÏ̵߳ÄÀà¿â×öÁË´óÁ¿µÄÀ©Õ¹£¬ÆäÖÐÏ̳߳ؾÍÊÇJava5µÄÐÂÌØÕ÷Ö®Ò»£¬³ýÁËÏ̳߳ØÖ®Í⣬»¹Óкܶà¶àÏß³ÌÏà¹ØµÄÄÚÈÝ£¬Îª¶àÏ̵߳ıà³Ì´øÀ´Á˼«´ó±ãÀû¡£ÎªÁ˱àд¸ßЧÎȶ¨¿É¿¿µÄ¶àÏ̳߳ÌÐò£¬Ï̲߳¿·ÖµÄÐÂÔöÄÚÈÝÏÔµÃÓÈΪÖØÒª¡£
ÓйØJava5Ïß³ÌÐÂÌØÕ÷µÄÄÚÈÝÈ«²¿ÔÚjava.util.concurrentÏÂÃ棬ÀïÃæ°üº¬ÊýÄ¿ÖÚ¶àµÄ½Ó¿ÚºÍÀ࣬ÊìϤÕⲿ·ÖAPIÌØÕ÷ÊÇÒ»Ïî¼èÄѵÄѧϰ¹ý³Ì¡£Ä¿Ç°ÓйØÕâ·½ÃæµÄ×ÊÁϺÍÊé¼®¶¼ÉÙÖ®ÓÖÉÙ£¬´óËùÊô½éÉÜÏ̷߳½ÃæÊé¼®»¹Í£ÁôÔÚjava5֮ǰµÄ֪ʶ²ãÃæÉÏ¡£
µ±È»ÐÂÌØÕ÷¶Ô×ö¶àÏ̳߳ÌÐòûÓбØÐëµÄ¹Øϵ£¬ÔÚjava5֮ǰͨÓÿÉÒÔд³öºÜÓÅÐãµÄ¶àÏ̳߳ÌÐò¡£Ö»ÊÇ´ú¼Û²»Ò»Ñù¶øÒÑ¡£
Ï̳߳صĻù±¾Ë¼Ï뻹ÊÇÒ»ÖÖ¶ÔÏó³ØµÄ˼Ï룬¿ª±ÙÒ»¿éÄÚ´æ¿Õ¼ä£¬ÀïÃæ´æ·ÅÁËÖڶࣨδËÀÍö£©µÄỊ̈߳¬³ØÖÐÏß³ÌÖ´Ðе÷¶ÈÓɳعÜÀíÆ÷À´´¦Àí¡£µ±ÓÐÏß³ÌÈÎÎñʱ£¬´Ó³ØÖÐÈ¡Ò»¸ö£¬Ö´ÐÐÍê³ÉºóÏ̶߳ÔÏó¹é³Ø£¬ÕâÑù¿ÉÒÔ±ÜÃâ·´¸´´´½¨Ï̶߳ÔÏóËù´øÀ´µÄÐÔÄÜ¿ªÏú£¬½ÚÊ¡ÁËϵͳµÄ×ÊÔ´¡£
ÔÚJava5֮ǰ£¬ÒªÊµÏÖÒ»¸öÏ̳߳ØÊÇÏ൱ÓÐÄѶȵģ¬ÏÖÔÚJava5ΪÎÒÃÇ×öºÃÁËÒ»ÇУ¬ÎÒÃÇÖ»ÐèÒª°´ÕÕÌṩµÄAPIÀ´Ê¹Ó㬼´¿ÉÏíÊÜÏ̳߳شøÀ´µÄ¼«´ó±ãÀû¡£
Java5µÄÏ̳߳طֺöàÖÖ£º¹Ì¶¨³ß´çµÄÏ̳߳ء¢¿É±ä³ß´çÁ¬½Ó³Ø¡¢¡£
ÔÚʹÓÃÏ̳߳Ø֮ǰ£¬±ØÐëÖªµÀÈçºÎÈ¥´´½¨Ò»¸öÏ̳߳أ¬ÔÚJava5ÖУ¬ÐèÒªÁ˽âµÄÊÇjava.util.concurrent.ExecutorsÀàµÄAPI£¬Õâ¸öÀàÌṩ´óÁ¿´´½¨Á¬½Ó³ØµÄ¾²Ì¬·½·¨£¬ÊDZØÐëÕÆÎյġ£
Ò»¡¢¹Ì¶¨´óСµÄÏ̳߳Ø
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
/**
* JavaỊ̈߳ºÏ̳߳Ø-
*
* @author Administrator 2009-11-4 23:30:44
*/
public class Test {
public static void main(String[] args) {
//´´½¨Ò»¸ö¿ÉÖØÓù̶¨Ïß³ÌÊýµÄÏ̳߳Ø
ExecutorService pool = Executors.newFixedThreadPool(2);
//´´½¨ÊµÏÖÁËRunnable½Ó¿Ú¶ÔÏó£¬Thread¶ÔÏóµ±È»Ò²ÊµÏÖÁËRunnable½Ó¿Ú
&
Ïà¹ØÎĵµ£º
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class JavaBasic {
public static void main(String[] args){
StringBuffer sd = new StringBuffer();
String hhhString="adlkll";
&nbs ......
´ò¿ªeclipse£¬·¢ÏÖeclipseå´µôÁË£¬²¢ÇÒ³öÏÖÕâÑùµÄÌáʾ£º¹ØÓÚInitializing java tooling£¨1%£©...
ÖØÆôÁ˼¸´ÎÖ®ºó·¢ÏÖÎÊÌâÈÔÈ»´æÔÚ£¬Òò¶ø¿ñËÑÁËÒ»°Ñ£¬ÖÕÓÚÕÒµ½ÕýÈ·µÄ½â¾ö°ì·¨£¬ÈçÏ£º
ÕÒµ½eclipseĿ¼£¬±à¼eclipse.iniÎļþ£¬ÔÚ-vmargs²ÎÊý֮ǰÌí¼ÓÉÏÈçϲÎÊý£¨Ò»¶¨ÒªÏñÏÂÃæÕâÑùд³ÉÁ½ÐУ©£¬È»ºóÖØÆô¾ÍokÁË
-vm
C:\Progr ......
JavaỊ̈߳ºÏ̵߳ĵ÷¶È-ÓÅÏȼ¶
ÓëÏß³ÌÐÝÃßÀàËÆ£¬Ï̵߳ÄÓÅÏȼ¶ÈÔÈ»ÎÞ·¨±£ÕÏÏ̵߳ÄÖ´ÐдÎÐò¡£Ö»²»¹ý£¬ÓÅÏȼ¶¸ßµÄÏ̻߳ñÈ¡CPU×ÊÔ´µÄ¸ÅÂʽϴó£¬ÓÅÏȼ¶µÍµÄ²¢·Çû»ú»áÖ´ÐС£
Ï̵߳ÄÓÅÏȼ¶ÓÃ1-10Ö®¼äµÄÕûÊý±íʾ£¬ÊýÖµÔ½´óÓÅÏȼ¶Ô½¸ß£¬Ä¬ÈϵÄÓÅÏȼ¶Îª5¡£
ÔÚÒ»¸öÏß³ÌÖпªÆôÁíÍâÒ»¸öÐÂỊ̈߳¬ÔòпªÏ̳߳ÆÎ ......
JavaỊ̈߳ºvolatile¹Ø¼ü×Ö
Java™ ÓïÑÔ°üº¬Á½ÖÖÄÚÔÚµÄͬ²½»úÖÆ£ºÍ¬²½¿é£¨»ò·½·¨£©ºÍ volatile ±äÁ¿¡£ÕâÁ½ÖÖ»úÖƵÄÌá³ö¶¼ÊÇΪÁËʵÏÖ´úÂëÏ̵߳ݲȫÐÔ¡£ÆäÖÐ Volatile ±äÁ¿µÄͬ²½ÐԽϲµ«ÓÐʱËü¸ü¼òµ¥²¢ÇÒ¿ªÏú¸üµÍ£©£¬¶øÇÒÆäʹÓÃÒ²¸üÈÝÒ׳ö´í¡£
̸¼°µ½volatile¹Ø¼ü×Ö£¬²»µÃ²»ÌáµÄһƪÎÄÕÂÊÇ£º¡¶Java ......