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º¯ÊýµÄ²ÎÊý´«µÝºÍStringÀàÐÍ http://www.blogjava.net/thuixy/archive/2009/06/06/280302.html
˵ÍêÁËjavaµÄStringÀàÐÍ£¬ÎÒÃÇ×îºó¿´¿´javaº¯Êý²ÎÊýµÄ´«µÝ£¬µ½µ×ÊÇÖµ´«µÝ»¹ÊÇÒýÓô«µÝÄØ£¿Ò»°ãµÄ˵·¨ÊǶÔÓÚ»ù±¾ÀàÐͱÈÈçint¡¢charÊÇÖµ´«µÝ£¬¶ÔÓÚ¶ÔÏóÀàÐÍÊÇÒýÓô«µÝ¡£ÕâÖÖ˵·¨Ã»´í£¬µ«ÊÇÇë¿´ÏÂÃæµÄÀý×Ó£º
Str ......
Genaral Principles Ò»°ãÔ¼¶¨
1.Adhere to the style
of the original.
±£³Ö×î³õµÄÑùʽ¡£
2.Adhere to the Principle of Least
Astonishment.
×ñÊØ×îС¾ªÆæÔÔò¡£
3.Do it right the first time.
µÚÒ»´Î¾ÍÓ¦µ±×öºÃ¡£
4.Document any deviations.
¶ÔÓÚÈκα³À붼Ӧµ±Îĵµ×¢ÊÍ¡£
Formatting
Convent ......
ÔÎijö´¦£ºhttp://java.csdn.net/a/20100308/259219.html
Ãô½Ý¿ª·¢µÄÀíÄîÒѾÁ÷ÐÐÁ˺ܳ¤µÄʱ¼ä£¬ÔÚÃô½Ý¿ª·¢ÖеĿª·¢µü´ú½×¶ÎÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÎå¸ö²½Ö裬À´ÓÐЧµÄÌá¸ßÕû¸öÏîÄ¿µÄ´úÂëÖÊÁ¿¡£
JavaÏîÄ¿¿ª·¢¹ý³ÌÖУ¬ÓÉÓÚ¿ª·¢ÈËÔ±µÄ¾Ñé¡¢Java´úÂë±àдϰ¹ß£¬ÒÔ¼°È±·¦Í³Ò»µÄ±ê×¼ºÍ¹ÜÀíÁ÷³Ì£¬ÍùÍùµ¼ÖÂÕû¸öÏîÄ¿µÄ´úÂëÖÊÁ¿½Ï²î£¬ÄÑÓ ......
// messages.hello.properties
id=001
name=ϧԵ
love=I think,therefor i am.
friends=Hi! {0} and {1} ,how are you?
// org.PropertiesUtil.java
package org;
import java.io.UnsupportedEncodingException;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceEx ......
JavaScriptºÍJavaµÄÇø±ð
¡¡¡¡ËäÈ»JavaScriptÓëJavaÓнôÃܵÄÁªÏµ£¬µ«È´ÊÇÁ½¸ö¹«Ë¾¿ª·¢µÄ²»Í¬µÄÁ½¸ö²úÆ·¡£JavaÊÇSUN¹«Ë¾ÍƳöµÄÐÂÒ»´úÃæÏò¶ÔÏóµÄ³ÌÐòÉè¼ÆÓïÑÔ£¬ÌرðÊʺÏÓÚInternetÓ¦ÓóÌÐò¿ª·¢£»¶øJavaScriptÊÇNetscape¹«Ë¾µÄ²úÆ·£¬ÆäÄ¿µÄÊÇΪÁËÀ©Õ¹Netscape Navigator¹¦ÄÜ,¶ø¿ª·¢µÄÒ»ÖÖ¿ÉÒÔǶÈëWebÒ³ÃæÖеĻùÓÚ¶ÔÏóºÍʼþÇý¶ ......