JAVAÖеĶàÏß³Ì
1¡¢ ÈÏʶThreadºÍRunnable
JavaÖÐʵÏÖ¶àÏß³ÌÓÐÁ½ÖÖ;¾¶£º¼Ì³ÐThreadÀà»òÕßʵÏÖRunnable½Ó¿Ú¡£RunnableÊǽӿڣ¬½¨ÒéÓýӿڵķ½Ê½Éú³ÉỊ̈߳¬ÒòΪ½Ó¿Ú¿ÉÒÔʵÏÖ¶à¼Ì³Ð£¬¿öÇÒRunnableÖ»ÓÐÒ»¸örun·½·¨£¬ºÜÊʺϼ̳С£ÔÚʹÓÃThreadµÄʱºòÖ»Ðè¼Ì³ÐThread£¬²¢ÇÒnewÒ»¸öʵÀý³öÀ´£¬µ÷ÓÃstart()·½·¨¼´¿ÉÒÔÆô¶¯Ò»¸öÏ̡߳£
Thread Test = new Thread();
Test.start();
ÔÚʹÓÃRunnableµÄʱºòÐèÒªÏÈnewÒ»¸öʵÏÖRunnableµÄʵÀý£¬Ö®ºóÆô¶¯Thread¼´¿É¡£
Test impelements Runnable;
Test t = new Test();
Thread test = new Thread(t);
test.start();
×ܽ᣺ThreadºÍRunnableÊÇʵÏÖjava¶àÏ̵߳Ä2ÖÖ·½Ê½£¬runableÊǽӿڣ¬threadÊÇÀ࣬½¨ÒéʹÓÃrunableʵÏÖjava¶àỊ̈߳¬²»¹ÜÈçºÎ£¬×îÖÕ¶¼ÐèҪͨ¹ýthread.start()À´Ê¹Ï̴߳¦ÓÚ¿ÉÔËÐÐ״̬¡£
2¡¢ ÈÏʶThreadµÄstartºÍrun
1£© start£º
ÓÃstart·½·¨À´Æô¶¯Ị̈߳¬ÕæÕýʵÏÖÁ˶àÏß³ÌÔËÐУ¬ÕâʱÎÞÐèµÈ´ýrun·½·¨Ìå´úÂëÖ´ÐÐÍê±Ï¶øÖ±½Ó¼ÌÐøÖ´ÐÐÏÂÃæµÄ´úÂ롣ͨ¹ýµ÷ÓÃThreadÀàµÄstart()·½·¨À´Æô¶¯Ò»¸öỊ̈߳¬Õâʱ´ËÏ̴߳¦ÓÚ¾ÍÐ÷£¨¿ÉÔËÐУ©×´Ì¬£¬²¢Ã»ÓÐÔËÐУ¬Ò»µ©µÃµ½spuʱ¼äƬ£¬¾Í¿ªÊ¼Ö´ÐÐrun()·½·¨£¬ÕâÀï·½·¨run()³ÆΪÏß³ÌÌ壬Ëü°üº¬ÁËÒªÖ´ÐеÄÕâ¸öÏ̵߳ÄÄÚÈÝ£¬Run·½·¨ÔËÐнáÊø£¬´ËÏß³ÌËæ¼´ÖÕÖ¹¡£
2£© run£º
run()·½·¨Ö»ÊÇÀàµÄÒ»¸öÆÕͨ·½·¨¶øÒÑ£¬Èç¹ûÖ±½Óµ÷ÓÃRun·½·¨£¬³ÌÐòÖÐÒÀȻֻÓÐÖ÷Ïß³ÌÕâÒ»¸öỊ̈߳¬Æä³ÌÐòÖ´Ðз¾¶»¹ÊÇÖ»ÓÐÒ»Ìõ£¬»¹ÊÇҪ˳ÐòÖ´ÐУ¬»¹ÊÇÒªµÈ´ýrun·½·¨ÌåÖ´ÐÐÍê±Ïºó²Å¿É¼ÌÐøÖ´ÐÐÏÂÃæµÄ´úÂ룬ÕâÑù¾ÍûÓдﵽдÏ̵߳ÄÄ¿µÄ¡£
×ܽ᣺µ÷ÓÃstart·½·¨·½¿ÉÆô¶¯Ị̈߳¬¶ørun·½·¨Ö»ÊÇthreadµÄÒ»¸öÆÕͨ·½·¨µ÷Ó㬻¹ÊÇÔÚÖ÷Ïß³ÌÀïÖ´ÐС£
3¡¢ Ïß³Ì״̬˵Ã÷
Ïß³Ì״̬´Ó´óµÄ·½ÃæÀ´Ëµ£¬¿É¹é½áΪ£º³õʼ״̬¡¢¿ÉÔËÐÐ״̬¡¢²»¿ÉÔËÐÐ״̬ºÍÏûÍö״̬£¬¾ßÌå¿Éϸ·ÖΪÉÏͼËùʾ7¸ö״̬£¬ËµÃ÷ÈçÏ£º
1£© Ï̵߳ÄʵÏÖÓÐÁ½ÖÖ·½Ê½£¬Ò»ÊǼ̳ÐThreadÀ࣬¶þÊÇʵÏÖRunnable½Ó¿Ú£¬µ«²»¹ÜÔõÑù£¬µ±ÎÒÃÇnewÁËthreadʵÀýºó£¬Ï߳̾ͽøÈëÁ˳õʼ״̬£»
2£© µ±¸Ã¶ÔÏóµ÷ÓÃÁËstart()·½·¨£¬¾Í½øÈë¿ÉÔËÐÐ״̬£»
3£© ½øÈë¿ÉÔËÐÐ״̬ºó£¬µ±¸Ã¶ÔÏó±»²Ù×÷ϵͳѡÖУ¬»ñµÃCPUʱ¼äƬ¾Í»á½øÈëÔËÐÐ״̬£»
4£© ½øÈëÔËÐÐ״̬ºócase¾Í±È½Ï¶à£¬´óÖÂÓÐÈçÏÂÇéÐΣº
﹒run()·½·¨»òmain()·½·¨½áÊøºó£¬Ï߳̾ͽøÈëÖÕֹ״̬£»
﹒µ±Ï̵߳÷ÓÃÁË×ÔÉíµÄsleep()·½·¨»òÆäËûÏ̵߳Äjoin()·½·¨£¬¾Í»á½øÈë×èÈû״̬(¸Ã״̬¼ÈÍ£Ö¹µ±Ç°Ị̈߳¬µ«²¢²»ÊÍ·ÅËùÕ¼ÓеÄ×ÊÔ´)¡£µ±sleep()½
Ïà¹ØÎĵµ£º
°æȨËùÓУ¬×ªÔØ×¢Ã÷³ö´¦£¡
תÔØÇëЯ´ø´ËÐÅÏ¢£ºhuangfox
-----------------------------------------------------------------
³éÏ󹤳§ºÍ¹¤³§·½·¨ ¸Õ¿ªÊ¼ºÜÈÝÒ×»ìÏý£¬ÖÁÉÙÎÒÊÇÕâÑùµÄ£¡
²»¹ýËûÃDzúÉúµÄÔµÓÉÀ´¿´£¬»¹ÊÇ¿ÉÒԺúÃÇø·ÖµÄ¡£
1.¹¤³§·½·¨£ºÊÇΪÁ˱ÜÃâÓ¦ÓÃÖ±½ÓʵÀýÀà²ã´Î½á¹¹ÖеľßÌåÀ࣬Ìṩһ¸ö·½·¨¸ù¾ÝÔËÐÐÇé ......
¾³£Óõ½µç¿ÏÂÔØ×ÊÁÏ,һЩhttpÄã¸ù±¾ÕÒ²»µ½µÄ×ÊÔ´,µ±È»ËÙ¶ÈÊDz»Äܹ§Î¬ÁË,¿×Óô,¸ÉµÄ¾ÍÊÇÂý»î,ÈÈÃÅ×ÊÔ´³ýÍâ…
ÎÒÓõÄverycd°æµÄµç¿,Ô°æµç¿µÄÒ»ÖÖmods,µç¿òËÆÓÐN¶à°æ±¾,²»¹ýÎÒ¾õµÃverycdµÄ¾Í¹»ÓÃÁË,±Ï¾¹¹úÄڰ˳ɵÄÈ˶¼ÔÚÓÃ.
×î½üÔÚÏÂж«·½µÄиÅÄîÓ¢Óï½Ì³Ì,½ø¶È87%,ÑÛ¿´ÒªÏÂÍêÁË,µÈÒªµÈ1¸ö¶àСʱ,ÏÂÔØÍê³ÉÓ ......
Java ByteCode
1£¬Ê²Ã´ÊÇBytecode
C/C++±àÒëÆ÷°ÑÔ´´úÂë±àÒë³É»ã±à´úÂ룬Java±àÒëÆ÷°ÑJavaÔ´´úÂë±àÒë³É×Ö½ÚÂëbytecode¡£
Java¿çƽ̨Æäʵ¾ÍÊÇ»ùÓÚÏàͬµÄbytecode¹æ·¶×ö²»Í¬Æ½Ì¨µÄÐéÄâ»ú£¬ÎÒÃǵÄJava³ÌÐò±àÒë³Ébytecodeºó¾Í¿ÉÒÔÔÚ²»Í¬Æ½Ì¨ÅÜÁË¡£
.net¿ò¼ÜÓÐIL(intermediate language)£¬»ã±àÊÇC/C++³ÌÐòµÄÖмä±í´ï·½Ê½£¬ ......
ÃæÏò¶ÔÏó³ÌÐòÉè¼Æ¹²ÓÐÈý´óÌØÐÔ£º·â×°¡¢¼Ì³Ð¡¢¶à̬£»
ÕâÈý´óÌØÐÔÖ®¼äÏ໥¹ØÁª£¬ÆäÖзâ×°ÐÔÊÇÃæÏò¶ÔÏóµÄ»ù´¡£¬¼Ì³ÐÐÔÊÇÈí¼þÖØÓõĹؼü¡£¶ø¶à̬ÐÔÔò±ØÐë´æÔÚÓڼ̳еĻ·¾³Ö®ÖУ¬ÊǶÔÃæÏò¶ÔÏó³ÌÐòÉè¼ÆµÄ²¹³ä¡£
·â×°£»
Java5.0ÐÂÌØÐÔ£»»ù±¾Êý¾ÝÀàÐÍà·â×°Àà ·âÏ䣻 ·â×°Ààà»ù±¾Êý¾ÝÀàÐÍ ²ðÏ䣻
package review;
......
ÍøÉÏÓÐÁ˺ܶàÕâÑùµÄÎÄÕ£¬²»¹ý¸Ð¾õ²¢²»ÊǺÜÈ«£¬ÎÒ¶¼¶«ÕÒÎ÷ÕÒ²Å×îÖÕ°ÑJAVAµ÷ÓÃc++¸ø¸ã¶¨¡£
ÏÂÃæÒýÓÃÁ˺ܶàÍøÉÏÒѾÓеĵÄÄÚÈÝ£¬ÎÒÔÚÕâÀïÖ»ÊÇÕûºÏÒ»´Î£¬ÈÃÒÔºóµÄÅóÓÑÉÙ×ßÍø·¡£
¶à˵ÎÞÒ棬¾ßÌåÈçÏ£º
×÷Õß:mykoma
¼ÙÉèËùÓÐÎļþ¶¼·ÅÔÚd:\
Step 1:
дJAVAÎļþ
ÀýÈç³ÌÐòtestdll.java£¬ÄÚÈÝΪ£º
......