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

JavaÏß³Ì֪ʶÉîÈë½âÎö(1)

Ò»°ãÀ´Ëµ,ÎÒÃÇ°ÑÕýÔÚ¼ÆËã»úÖÐÖ´ÐеijÌÐò½Ð×ö"½ø³Ì"(Process) ,¶ø²»½«Æä³ÆΪ³ÌÐò(Program)¡£Ëùν"Ïß³Ì"(Thread),ÊÇ"½ø³Ì"ÖÐij¸öµ¥Ò»Ë³ÐòµÄ¿ØÖÆÁ÷¡£ÐÂÐ˵IJÙ×÷ϵͳ,ÈçMac,Windows NT,Windows 95µÈ,´ó¶à²ÉÓöàÏ̵߳ĸÅÄî,°ÑÏß ³ÌÊÓΪ»ù±¾Ö´Ðе¥Î»¡£Ïß³ÌÒ²ÊÇJavaÖеÄÏ൱ÖØÒªµÄ×é³É²¿·ÖÖ®Ò»¡£
ÉõÖÁ×î¼òµ¥µÄAppletÒ²ÊÇÓɶà¸öÏß³ÌÀ´Íê³ÉµÄ¡£ÔÚJavaÖÐ,ÈκÎÒ»¸öAppletµÄpaint()ºÍupdate()·½·¨¶¼ÊÇÓÉAWT(Abstract Window Toolkit)»æͼÓëʼþ´¦ÀíÏ̵߳÷ÓõÄ,¶øApplet Ö÷ÒªµÄÀï³Ì±®·½·¨——init(),start(),stop()ºÍdestory() ——ÊÇÓÉÖ´ÐиÃAppletµÄÓ¦Óõ÷Óõġ£
µ¥Ï̵߳ĸÅÄîûÓÐʲôеĵط½,ÕæÕýÓÐȤµÄÊÇÔÚÒ»¸ö³ÌÐòÖÐͬʱʹÓöà¸öÏß³ÌÀ´Íê³É²»Í¬µÄÈÎÎñ¡£Ä³Ð©µØ·½ÓÃÇáÁ¿½ø³Ì(Lightweig ht Process)À´´úÌæÏß³Ì,Ïß³ÌÓëÕæÕý½ø³ÌµÄÏàËÆÐÔÔÚÓÚËüÃǶ¼Êǵ¥Ò»Ë³Ðò¿ØÖÆÁ÷¡£È»¶øÏ̱߳»ÈÏΪÇáÁ¿ÊÇÓÉÓÚËüÔËÐÐÓÚÕû¸ö³ÌÐòµÄÉÏÏÂÎÄÄÚ,ÄÜʹÓÃÕû¸ö³ÌÐò¹²ÓеÄ×ÊÔ´ºÍ³ÌÐò»·¾³¡£
×÷Ϊµ¥Ò»Ë³Ðò¿ØÖÆÁ÷,ÔÚÔËÐеijÌÐòÄÚÏ̱߳ØÐëÓµÓÐһЩ×ÊÔ´×÷Ϊ±ØÒªµÄ¿ªÏú¡£ÀýÈç,±ØÐëÓÐÖ´ÐжÑÕ»ºÍ³ÌÐò¼ÆÊýÆ÷ÔÚÏß³ÌÄÚÖ´ÐеĴúÂëÖ»ÔÚËüµÄÉÏÏÂÎÄÖÐÆð×÷ÓÃ,Òò´ËijЩµØ·½ÓÃ"Ö´ÐÐÉÏÏÂÎÄ"À´´úÌæ"Ïß³Ì"¡£
Ïß³ÌÊôÐÔ
ΪÁËÕýÈ·ÓÐЧµØʹÓÃÏß³Ì,±ØÐëÀí½âÏ̵߳ĸ÷¸ö·½Ãæ²¢Á˽âJava ʵʱϵͳ¡£±ØÐëÖªµÀÈçºÎÌṩÏß³ÌÌå¡¢Ï̵߳ÄÉúÃüÖÜÆÚ¡¢ÊµÊ±ÏµÍ³ÈçºÎµ÷¶ÈÏ̡߳¢Ïß³Ì×顢ʲôÊÇÓÄÁéÏß³Ì(Demo nThread)¡£
(1)Ïß³ÌÌå
ËùÓеIJÙ×÷¶¼·¢ÉúÔÚÏß³ÌÌåÖÐ,ÔÚJavaÖÐÏß³ÌÌåÊÇ´ÓThreadÀà¼Ì³ÐµÄrun()·½·¨,»òʵÏÖRunnable½Ó¿ÚµÄÀàÖеÄrun()·½·¨¡£µ±Ï̲߳úÉú²¢³õʼ»¯ºó,ʵʱϵͳµ÷ÓÃËüµÄrun()·½·¨¡£run()·½·¨ÄڵĴúÂëʵÏÖËù²úÉúÏ̵߳ÄÐÐΪ,ËüÊÇÏ̵߳ÄÖ÷Òª²¿
·Ö¡£
(2)Ïß³Ì״̬
¸½Í¼±íʾÁËÏß³ÌÔÚËüµÄÉúÃüÖÜÆÚÄÚµÄÈκÎʱ¿ÌËùÄÜ´¦µÄ״̬ÒÔ¼°ÒýÆð״̬¸Ä±äµÄ·½·¨¡£Õâͼ²¢²»ÊÇÍêÕûµÄÓÐÏÞ״̬ͼ,µ«»ù±¾¸ÅÀ¨ÁËÏß³ÌÖбȽϸÐÐËȤºÍÆÕ±éµÄ·½Ãæ¡£ÒÔÏÂÌÖÂÛÓйØÏß³ÌÉúÃüÖÜÆÚÒÔ´ËΪ¾Ý¡£
¡ñÐÂÏß³Ì̬(New Thread)
²úÉúÒ»¸öThread¶ÔÏó¾ÍÉú³ÉÒ»¸öÐÂÏ̡߳£µ±Ï̴߳¦ÓÚ"ÐÂÏß³Ì"״̬ʱ,½ö½öÊÇÒ»¸ö¿ÕÏ̶߳ÔÏó,Ëü»¹Ã»ÓзÖÅ䵽ϵͳ×ÊÔ´¡£Òò´ËÖ»ÄÜÆô¶¯»òÖÕÖ¹Ëü¡£ÈκÎÆäËû²Ù×÷¶¼»áÒý·¢Òì³£¡£
¡ñ¿ÉÔËÐÐ̬(Runnable)
start()·½·¨²úÉúÔËÐÐÏß³ÌËù±ØÐëµÄ×ÊÔ´,µ÷¶ÈÏß³ÌÖ´ÐÐ,²¢ÇÒµ÷ÓÃÏ̵߳Ärun ()·½·¨¡£ÔÚÕâʱÏ̴߳¦ÓÚ¿ÉÔËÐÐ̬¡£¸Ã״̬²»³ÆΪÔËÐÐ̬ÊÇÒòΪÕâʱµÄÏ̲߳¢²»×ÜÊÇÒ»Ö±Õ¼Óô¦Àí»ú¡£ÌرðÊǶÔÓÚÖ»ÓÐÒ»¸ö´¦Àí»úµÄPC¶øÑÔ,Èκ


Ïà¹ØÎĵµ£º

Javaµ÷ÓÃWMICÃüÁîµÄ·½·¨

    ½ñÌìҪд¸öÔ¶³ÌÖØÆô·þÎñµÄ¹¦ÄÜ£¬ÎªÁË¿ª·¢Ëٶȣ¬ÔÝʱ¶¨ÎªJava´úÂë+WMICÃüÁîµÄ·½·¨£¬¼òµ¥µÄ˵£¬¾ÍÊÇÀûÓÃJavaµ÷Óñ¾»úÓ¦ÓóÌÐòµÄ·½·¨¡£Éæ¼°µ½µÄJavaÀàÓÐjava.lang°üÀïÃæµÄRuntime¡¢Process¡¢ProcessBuilderÈý¸öÀ࣬ÒÔ¼°wmicÖÐÖØÆô·þÎñµÄÃüÁî¡£ÒòΪ֮ǰҲд¹ýÕâ·½ÃæµÄ¶«Î÷£¬ËùÒÔºÜÏ°¹ßÐÔµÄд³öÁË´úÂ룺
&nb ......

JavaÖÐÏà¶Ô·¾¶£¬¾ø¶Ô·¾¶ÎÊÌâ×ܽá


1.»ù±¾¸ÅÄîµÄÀí½â
¾ø¶Ô·¾¶£º¾ø¶Ô·¾¶¾ÍÊÇÄãµÄÖ÷Ò³ÉϵÄÎļþ»òĿ¼ÔÚÓ²ÅÌÉÏÕæÕýµÄ·¾¶£¬(URLºÍÎïÀí·¾¶)ÀýÈ磺 C:\xyz\test.txt ´ú±íÁËtest.txtÎļþµÄ¾ø¶Ô·¾¶¡£http://www.sun.com/index.htmÒ²´ú±íÁËÒ»¸ö URL¾ø¶Ô·¾¶¡£
Ïà¶Ô·¾¶£ºÏà¶ÔÓëij¸ö»ù׼Ŀ¼µÄ·¾¶¡£°üº¬WebµÄÏà¶Ô·¾¶(HTMLÖеÄÏà¶ÔĿ¼)£¬ÀýÈ磺ÔÚ ServletÖУ ......

java±ÊÊÔ1

1. HttpSession session = request.getSession() 
ÓëHttpSession session = request.getSession(true)µÄÇø±ð£¿ 
²Î¿¼´ð°¸£º 
getSession(true)µÄº¯ÊýÔ­ÐÍΪ:£ºHttpSession session = request.getSession (Boolean create) 
Èç¹ûÓÐÓ뵱ǰµÄrequestÏȹØÁªµÄHttpSession,ÄÇô·µ»ØrequestÏà¹ØÁªµÄHttpS ......

ArrayListÖеÄÊý¾ÝÅÅÐò java¶ÔÏóÅÅÐò

³£³£Óöµ½Êý×éÅÅÐòµÄÎÊÌâ.±ÈÈçÎÒÓÐÒ»¸öPersonÀà,ËüµÄʵÀý¶ÔÏó´æ´¢ÔÚArrayListÊý×éÖÐ,ÏÖÔÚÒª°ÑArrayListÊý×éÖеÄPerson¶ÔÏó°´ÕÕÄêÁäÅÅÐò.
ÆäʵÕâÖÖÇé¿ö¾­³£Óöµ½.
ÏÂÃæ¸ø³öÔ´´úÂë:
1:Person.JavaÎļþ:-------------------------------
public class Person{
String name;
int age;
public Person(String name,int age){ ......

Java¶àÏ̵߳ÄÏà¹Ø»úÖÆ

Ò» Ï̵߳Ļù±¾¸ÅÄî
Ïß³ÌÊÇÒ»¸ö³ÌÐòÄÚ²¿µÄ˳Ðò¿ØÖÆÁ÷.Ò»¸ö½ø³ÌÏ൱ÓÚÒ»¸öÈÎÎñ,Ò»¸öÏß³ÌÏ൱ÓÚÒ»¸öÈÎÎñÖеÄÒ»ÌõÖ´Ðз¾¶.£»¶à½ø³Ì:ÔÚ²Ù×÷ϵͳÖÐÄÜͬʱÔËÐжà¸öÈÎÎñ(³ÌÐò)£»¶àÏß³Ì:ÔÚͬһ¸öÓ¦ÓóÌÐòÖÐÓжà¸ö˳ÐòÁ÷ͬʱִÐУ»JavaµÄÏß³ÌÊÇͨ¹ýjava.lang.ThreadÀàÀ´ÊµÏֵģ»JVMÆô¶¯Ê±»áÓÐÒ»¸öÓÉÖ÷·½·¨(public static void main( ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ