JavaỊ̈߳º´´½¨ÓëÆô¶¯
JavaỊ̈߳º´´½¨ÓëÆô¶¯
SCJP5ѧϰ±Ê¼Ç
Ò»¡¢¶¨ÒåÏß³Ì
1¡¢À©Õ¹java.lang.ThreadÀà¡£
´ËÀàÖÐÓиörun()·½·¨£¬Ó¦¸Ã×¢ÒâÆäÓ÷¨£º
public void run()
Èç¹û¸ÃÏß³ÌÊÇʹÓöÀÁ¢µÄ Runnable ÔËÐжÔÏó¹¹ÔìµÄ£¬Ôòµ÷Óøà Runnable ¶ÔÏóµÄ run ·½·¨£»·ñÔò£¬¸Ã·½·¨²»Ö´ÐÐÈκβÙ×÷²¢·µ»Ø¡£
Thread µÄ×ÓÀàÓ¦¸ÃÖØд¸Ã·½·¨¡£
2¡¢ÊµÏÖjava.lang.Runnable½Ó¿Ú¡£
void run()
ʹÓÃʵÏÖ½Ó¿Ú Runnable µÄ¶ÔÏó´´½¨Ò»¸öÏß³Ìʱ£¬Æô¶¯¸ÃÏ߳̽«µ¼ÖÂÔÚ¶ÀÁ¢Ö´ÐеÄÏß³ÌÖе÷ÓöÔÏóµÄ run ·½·¨¡£
·½·¨ run µÄ³£¹æж¨ÊÇ£¬Ëü¿ÉÄÜÖ´ÐÐÈκÎËùÐèµÄ²Ù×÷¡£
¶þ¡¢ÊµÀý»¯Ïß³Ì
1¡¢Èç¹ûÊÇÀ©Õ¹java.lang.ThreadÀàµÄỊ̈߳¬ÔòÖ±½Ónew¼´¿É¡£
2¡¢Èç¹ûÊÇʵÏÖÁËjava.lang.Runnable½Ó¿ÚµÄÀ࣬ÔòÓÃThreadµÄ¹¹Ôì·½·¨£º
Thread(Runnable target)
Thread(Runnable target, String name)
Thread(ThreadGroup group, Runnable target)
Thread(ThreadGroup group, Runnable target, String name)
Thread(ThreadGroup group, Runnable target, String name, long stackSize)
Èý¡¢Æô¶¯Ïß³Ì
ÔÚÏ̵߳ÄThread¶ÔÏóÉϵ÷ÓÃstart()·½·¨£¬¶ø²»ÊÇrun()»òÕß±ðµÄ·½·¨¡£
ÔÚµ÷ÓÃstart()·½·¨Ö®Ç°£ºÏ̴߳¦ÓÚÐÂ״̬ÖУ¬ÐÂ״ָ̬ÓÐÒ»¸öThread¶ÔÏ󣬵«»¹Ã»ÓÐÒ»¸öÕæÕýµÄÏ̡߳£
ÔÚµ÷ÓÃstart()·½·¨Ö®ºó£º·¢ÉúÁËһϵÁи´ÔÓµÄÊÂÇé
Æô¶¯ÐµÄÖ´ÐÐỊ̈߳¨¾ßÓÐеĵ÷ÓÃÕ»£©£»
¸ÃÏ̴߳ÓÐÂ״̬תÒƵ½¿ÉÔËÐÐ״̬£»
µ±¸ÃÏ̻߳ñµÃ»ú»áÖ´ÐÐʱ£¬ÆäÄ¿±êrun()·½·¨½«ÔËÐС£
×¢Ò⣺¶ÔJavaÀ´Ëµ£¬run()·½·¨Ã»ÓÐÈκÎÌرðÖ®´¦¡£Ïñmain()·½·¨Ò»Ñù£¬ËüÖ»ÊÇÐÂÏß³ÌÖªµÀµ÷Óõķ½·¨Ãû³Æ(ºÍÇ©Ãû)¡£Òò´Ë£¬ÔÚRunnableÉÏ»òÕßThreadÉϵ÷ÓÃrun·½·¨ÊǺϷ¨µÄ¡£µ«²¢²»Æô¶¯ÐµÄÏ̡߳£
ËÄ¡¢Àý×Ó
1¡¢ÊµÏÖRunnable½Ó¿ÚµÄ¶àÏß³ÌÀý×Ó
/**
* ʵÏÖRunnable½Ó¿ÚµÄÀà
*
* @author leizhimin 2008-9-13 18:12:10
*/
public class DoSomething implements Runnable {
private String name;
public DoSomething(String name) {
this.name = name;
}
public void run() {
for (
Ïà¹ØÎĵµ£º
JAVA·´Éä»úÖÆÊÇÔÚÔËÐÐ״̬ÖУ¬¶ÔÓÚÈÎÒâÒ»¸öÀ࣬¶¼Äܹ»ÖªµÀÕâ¸öÀàµÄËùÓÐÊôÐԺͷ½·¨£»¶ÔÓÚÈÎÒâÒ»¸ö¶ÔÏ󣬶¼Äܹ»µ÷ÓÃËüµÄÈÎÒâÒ»¸ö·½·¨£»ÕâÖÖ¶¯Ì¬»ñÈ¡µÄÐÅÏ¢ÒÔ¼°¶¯Ì¬µ÷ÓöÔÏóµÄ·½·¨µÄ¹¦ÄܳÆΪjavaÓïÑԵķ´Éä»úÖÆ¡£
package mypakage;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; ......
×÷ΪJava³ÌÐòÔ±À´Ëµ£¬×îÍ´¿àµÄÊÂÇéĪ¹ýÓÚ¿ÉÒÔÑ¡ÔñµÄ·¶Î§Ì«¹ã£¬¿ÉÒÔ¶ÁµÄÊéÌ«¶à£¬ÍùÍùÈÝÒ×ÎÞËùÊÊ´Ó¡£ÎÒÏë¾ÍÎÒ×Ô¼º¶Á¹ýµÄ¼¼ÊõÊé¼®ÖÐÌôÑ¡³öÀ´Ò»Ð©£¬°´ÕÕѧϰµÄÏȺó˳Ðò£¬ÍƼö¸ø´ó¼Ò£¬ÌرðÊÇÄÇЩÏë²»¶ÏÌá¸ß×Ô¼º¼¼ÊõˮƽµÄJava³ÌÐòÔ±ÃÇ¡£
¡¡¡¡Ò»¡¢Java±à³ÌÈëÃÅÀà
¡¡¡¡¶ÔÓÚûÓÐJava±à³Ì¾ÑéµÄJava³ÌÐòÔ±ÒªÈëÃÅ£¬Ëæ±ã¶ÁʲôÈëÃÅÊé ......
Ò»¡¢¹ú¼Ê»¯ºÍ Java ±à³ÌÓïÑÔ
ºÍ´ó¶àÊýʹÓÃÆäËüÓïÑԵijÌÐòÔ±²»Í¬£¬Java
³ÌÐòÔ±ÊÇ´óÁ¿¹¹½¨ÔÚ JDK ÖÐÌṩ I18N Ö§³ÖµÄ±ê×¼´úÂëµÄÊÜÒæÕß¡£´ó²¿·Ö´úÂë×î³õÀ´×Ô IBM µÄ Taligent ×Ó¹«Ë¾£¨×ԴӺϲ¢½ø
IBM ÒԺ󣩣¬´ú±íÁËÐí¶àÈËÄêµÄ¹¤×÷³É¹û£¬±È´ó¶àÊý¹«Ë¾¶À×ÔÔÚÆä²úÆ·ÖÐÌṩµÄ´úÂëÒªÇÐʵ¿ÉÐеöࡣ
ÕâЩ
´úÂë ......
1.Ì⣺javaÀúÊ·£¿
´ð£ºJava Ö®¸¸Golsling
1995 Äê5 ÔÂ23 ÈÕ Java µ®Éú
1998 Äê12 ÔÂ 1.2 °æ±¾Java2 J2SE J2EE J2ME
2004 Äê12 ÔÂ 1.5 °æ±¾(5.0) Java JavaSE JavaEE JavaME
2.Ì⣺JavaSE£¬JavaEE£¬JavaME£¿
´ð£ºJavaSE ---Java ±ê׼ƽ̨
JavaEE ---ÆóÒµ¼ ......
public class test1
{
public static void main(String[] args){
//== ÓëequalsµÄÇø±ð
//1.nullµÄ±È½Ï£ºÖ»ÄÜÓÃ==
System.out.println("1.nullµÄ±È½Ï£ºÖ»ÄÜÓÃ==");
Object o1=null,o2=null;
System.out.println(null==null&&o1==null& ......