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

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

Ò» Ï̵߳Ļù±¾¸ÅÄî
Ïß³ÌÊÇÒ»¸ö³ÌÐòÄÚ²¿µÄ˳Ðò¿ØÖÆÁ÷.Ò»¸ö½ø³ÌÏ൱ÓÚÒ»¸öÈÎÎñ,Ò»¸öÏß³ÌÏ൱ÓÚÒ»¸öÈÎÎñÖеÄÒ»ÌõÖ´Ðз¾¶.£»¶à½ø³Ì:ÔÚ²Ù×÷ϵͳÖÐÄÜͬʱÔËÐжà¸öÈÎÎñ(³ÌÐò)£»¶àÏß³Ì:ÔÚͬһ¸öÓ¦ÓóÌÐòÖÐÓжà¸ö˳ÐòÁ÷ͬʱִÐУ»JavaµÄÏß³ÌÊÇͨ¹ýjava.lang.ThreadÀàÀ´ÊµÏֵģ»JVMÆô¶¯Ê±»áÓÐÒ»¸öÓÉÖ÷·½·¨(public static void main(){})Ëù¶¨ÒåµÄỊ̈߳»¿ÉÒÔͨ¹ý´´½¨ThreadµÄʵÀýÀ´´´½¨ÐµÄỊ̈߳»Ã¿¸öÏ̶߳¼ÊÇͨ¹ýij¸öÌض¨Thread¶ÔÏóËù¶ÔÓ¦µÄ·½·¨run()À´Íê³ÉÆä²Ù×÷µÄ,·½·¨run()³ÆΪÏß³ÌÌ壬ͨ¹ýµ÷ÓÃThreadÀàµÄstart()·½·¨À´Æô¶¯Ò»¸öÏ̡߳£
¶þ Ï̵߳Ĵ´½¨ºÍÆô¶¯
¿ÉÒÔÓÐÁ½ÖÖ·½Ê½´´½¨ÐµÄÏß³Ì:
µÚÒ»ÖÖ:
1.¶¨ÒåÏß³ÌÀàʵÏÖRunnable½Ó¿Ú
2.Thread myThread = new Thread(target);   //targetΪRunnable½Ó¿ÚÀàÐÍ
3.RunnableÖÐÖ»ÓÐÒ»¸ö·½·¨:public void run();ÓÃÒÔ¶¨ÒåÏß³ÌÔËÐÐÌå
4.ʹÓÃRunnable½Ó¿Ú¿ÉÒÔΪ¶à¸öÏß³ÌÌṩ¹²ÏíµÄÊý¾Ý
5.ÔÚʵÏÖRunnable½Ó¿ÚµÄÀàµÄrun()·½·¨¶¨ÒåÖпÉÒÔʹÓÃThreadµÄ¾²Ì¬·½·¨public static Thread currentThread();»ñÈ¡µ±Ç°Ï̵߳ÄÒýÓÃ
µÚ¶þÖÖ:
1.¿ÉÒÔ¶¨ÒåÒ»¸öThreadµÄ×ÓÀಢÖØдÆärun·½·¨Èç:
class MyThread extends Thread {
public void run() {...}
}
2.È»ºóÉú³É¸ÃÀàµÄ¶ÔÏó:
MyThread myThread = new MyThread();
Èý Ï߳̿ØÖƵĻù±¾·½·¨
isAlive():ÅжÏÏß³ÌÊÇ·ñ»¹"»î"×Å
getPriority():»ñµÃÏ̵߳ÄÓÅÏȼ¶ÊýÖµ
setPriority():ÉèÖÃÏ̵߳ÄÓÅÏȼ¶ÊýÖµ
Thread.sleep():½«µ±Ç°Ïß³Ì˯ÃßÖ¸¶¨ºÁÃëÊý
join():µ÷ÓÃijÏ̵߳ĸ÷½·¨,½«µ±Ç°Ïß³ÌÓë¸ÃÏß³Ì"ºÏ²¢",¼´µÈ´ý¸ÃÏ߳̽áÊø,ÔÙ»Ö¸´µ±Ç°Ï̵߳ÄÔËÐÐ
yield():Èóöcpu,µ±Ç°Ï߳̽øÈë¾ÍÐ÷¶ÓÁеȴýµ÷¶È
wait():µ±Ç°Ï߳̽øÈë¶ÔÏóµÄwait pool
notify()/notifyAll():»½ÐѶÔÏóµÄwait poolÖеÄÒ»¸ö/ËùÓеȴýÏß³Ì
ËÄ Ïß³Ìͬ²½
ʵÏÖÉú²úÕßÏû·ÑÕßÎÊÌâÀ´ËµÃ÷Ïß³ÌÎÊÌâ,¾ÙÀýÈçÏÂËùʾ:
/**
* Éú²úÕßÏû·ÑÕßÎÊÌâ
*/
package com.basic.thread;
/**
* @author johnston678
*
* @version 2009-05-06
*/
public class ProducerConsumer {
/**
* @param args
*/
public static void main(String[] args) {
ProductBox pb = new ProductBox();
Producer p = new Producer(pb);
Consumer c = new Consumer(pb);

Thread pThread =


Ïà¹ØÎĵµ£º

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Éú³ÉÊý×ÖÖ¤Êé·½·¨

Java ÖÐÉú³ÉÊý×ÖÖ¤ÊéÒ²ºÜ¼òµ¥µÄ¡£
1¡¢´´½¨Ö¤Êé
Java ÖÐµÄ keytool.exe £¨Î»ÓÚ JDKBin Ŀ¼Ï£©¿ÉÒÔÓÃÀ´´´½¨Êý×ÖÖ¤Ê飬ËùÓеÄÊý×ÖÖ¤ÊéÊÇÒÔÒ»ÌõÒ»Ìõ(²ÉÓñðÃûÇø±ð)µÄÐÎʽ´æÈëÖ¤Êé¿âµÄÖУ¬Ö¤Êé¿âÖеÄÒ»ÌõÖ¤Êé°üº¬¸ÃÌõÖ¤ÊéµÄ˽Կ£¬¹«Ô¿ºÍ¶ÔÓ¦µÄÊý×ÖÖ¤ÊéµÄÐÅÏ¢¡£Ö¤Êé¿âÖеÄÒ»ÌõÖ¤Êé¿ÉÒÔµ¼³öÊý×ÖÖ¤ÊéÎļþ£¬Êý×ÖÖ¤ÊéÎļþÖ»°üÀ¨ ......

javaÉè¼Æģʽѧϰ1£­£­Singleton Pattern

javaÉè¼Æģʽѧϰ1£­£­Singleton Pattern
¡¡¡¡Ç°Ð©Ìì°ÚŪjava£¬²Î¿¼Ò»Ð©×ÊÁÏдÁ˸öÊý¾Ý¿âÁ¬½Ó³Ø£¬¶ÔÀïÃæÖ»²úÉúÒ»¸öʵÀýµÄÄÇÖÖ×ö·¨Éî±íÅå·þ£¬½ñÌìÖÐÎçÓÖÌýµ½±ðÈËÔÚ˵Éè¼Æģʽ£¬Êܲ»ÁËÁË£¬¾ÍÉÏÍøDownÁ˵ã×ÊÁÏÀ´¡£
¡¡¡¡Ò»À´¾Í¿´µ½ÁËSingletonģʽ£¬Ò»¿´£¬Ñ½£¬²»¾ÍÊÇÄǸöÁ¬½Ó³ØÀïÓõķ½·¨Ã´?!àÞ£¬Ô­À´Èç´Ë¡£
¡¡¡¡Singleton Ê ......

JavaдµÄÌ°³ÔÉß

     ÈýÖÜÇ°£¬¾ÍÓëͬѧԼ¶¨ºÃÁË£¬»¨ÈýÖÜʱ¼äд¸öÌ°³ÔÉߣ¬¾ÍÓÃ×Ô¼ºÏÖÔÚËùѧµÄJava£¬ÎÒÏë¿ÉÒÔ°¡¡£Ñ§Ð£Àï½Ì²»³öʲô¶«Î÷£¬ÄǾÍ×Ô¼º¸ã°É£¡ÓÚÊÇÎÒÃÇÐÅÊĵ©µ©¿ªÊ¼Á˼¸Ìì¡£²»ÁÏÎåÒ»Ò»À´£¬°ÑËùÓеĶ¼À­ÏÂÁË¡£×îºóÒ»ÖÜÁË£¬Ã»°ì·¨£¬Í¨Ïü°É£¡ÓÚÊÇÁ¬Ðø¼¸Ìì¿à¸É£¬ÖÕÓÚд³öÀ´ÁË.ËäÈ»Óеã´Ö²Ú£¬ÒòΪѧУ»¹Ã»¿ªÊ¼½ÌGUIº ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ