javaµÄ¶¨Ê±Æ÷ʹÓ÷½·¨
java¶¨Ê±Æ÷µÄʹÓÃ
¶¨Ê±Æ÷ÀàTimerÔÚjava.util°üÖС£Ê¹ÓÃʱ£¬ÏÈʵÀý»¯£¬È»ºóʹÓÃʵÀýµÄschedule(TimerTask task, long delay)·½·¨£¬É趨ָ¶¨µÄÈÎÎñtaskÔÚÖ¸¶¨µÄÑÓ³ÙdelayºóÖ´ÐС£¶¨Ê±Æ÷ÈÎÎñÀàTimerTaskÊdzéÏóÀ࣬¼Ì³Ð²¢ÖØдÆärun()·½·¨£¬¿ÉʵÏÖ¾ßÌåÈÎÎñ¡£
schedule(TimerTask task, Date time)É趨ָ¶¨ÈÎÎñtaskÔÚÖ¸¶¨Ê±¼ätimeÖ´ÐС£
cancel()·½·¨½áÊøÕâ¸ö¶¨Ê±Æ÷¡£
schedule(TimerTask task, long delay, long period)·½·¨É趨ָ¶¨ÈÎÎñtaskÔÚÖ¸¶¨ÑÓ³Ùdelayºó½øÐй̶¨ÑÓ³ÙperoidµÄÖ´ÐС£
scheduleAtFixedRate(TimerTask task, long delay, long period)·½·¨É趨ָ¶¨ÈÎÎñtaskÔÚÖ¸¶¨ÑÓ³Ùdelayºó½øÐй̶¨ÆµÂÊperoidµÄÖ´ÐС£
ҪʵÏÖÒ»¸ö¶¨Ê±ÈÎÎñ£¬ÔËÓÃjavaÖеÄTimerºÍTimerTaskÀà¿ÉÒԷdz£ÈÝÒ×ʵÏÖʵʱµ÷Óô¦Àíº¯Êý¡£ÕâÁ½¸öÀàʹÓÃÆðÀ´·Ç³£·½±ã£¬¿ÉÒÔÍê³ÉÎÒÃǶԶ¨Ê±Æ÷µÄ¾ø´ó¶àÊýÐèÒª¡£
¿´¸ö¼òµ¥µÄÀý×Ó:
import java.io.IOException;
import java.util.Timer;
public class TimerTest {
public static void main(String[] args){
Timer timer = new Timer();
//Ò²¿ÉÒÔ×Ô¶¨Òåʱ¼ä£º
//µÚÒ»¸ö±íʾִÐеÄʱ¼ä£¬µÚ¶þ¸ö±íʾ¸ô¶à³¤Ê±¼äÖ´ÐС£
timer.schedule(new MyTask(), new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse("2010-5-31 18:23:50"), 2000);
timer.schedule(new MyTask(), 1000, 2000);//ÔÚ1ÃëºóÖ´ÐдËÈÎÎñ,ÿ´Î¼ä¸ô2Ãë,Èç¹û´«µÝÒ»¸öData²ÎÊý,¾Í¿ÉÒÔÔÚij¸ö¹Ì¶¨µÄʱ¼äÖ´ÐÐÕâ¸öÈÎÎñ.
while(true){//Õâ¸öÊÇÓÃÀ´Í£Ö¹´ËÈÎÎñµÄ,·ñÔò¾Íһֱѻ·Ö´ÐдËÈÎÎñÁË
try {
int ch = System.in.read();
if(ch-'c'==0){
timer.cancel();//ʹÓÃÕâ¸ö·½·¨Í˳öÈÎÎñ
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
static class MyTask extends java.util.TimerTask{
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("________");
}
}
}
±¾ÎÄÀ´×ÔCSDN²©¿Í£¬×ªÔØÇë±êÃ÷³ö´¦£ºhttp://blog.csdn.net/sunny3106/archive/2007/05/17/1612952.aspx
Ïà¹ØÎĵµ£º
Java
ÃüÁîÐй¤¾ß×ܽá
1¡¢ÃüÁî
C\Documents and Settings\Zianed>ls ‘%JAVA_HOME%’/bin
HtmlConverter.exe javap.exe jstatd.exe rmid.exe
appletviewer.exe javaw.exe &n ......
ʹÓÃJava»ñÈ¡IPµØַʵÀý
ÎÄÕ·ÖÀà:Java±à³Ì
ÏÖÔÚÔÚ´ÓÊµĹ¤×÷³öÏÖÁËÒ»¸öÎÊÌ⣬ż¶û»á³öÏÖÈ¡²»µ½ipµÄÇé¿ö£¬ËÑË÷ÁËһϣ¬ÔÀ´ÈçÏÂÎÄËù˵
ת×Ô£ºhttp://developer.51cto.com/art/200906/130491.htm
ʹÓÃJava»ñÈ¡IPµØַʵÀý
ÔÚJSPÀ»ñÈ¡¿Í»§¶ËµÄIPµØÖ·µÄ·½·¨ÊÇ£ºrequest.getRemoteAddr()£¬ÕâÖÖ·½·¨Ôڴ󲿷ÖÇé¿ö϶¼Ê ......
ÕâÀïתÔØһƪ½²½âjavaÐòÁл¯(Serializable)ºÍ·´ÐòÁл¯·½ÃæµÄ¸Ð¾õºÜºÃµÄÎÄÕ¡£
1¡¢ÐòÁл¯ÊǸÉʲôµÄ£¿
¼òµ¥Ëµ¾ÍÊÇΪÁ˱£´æÔÚÄÚ´æÖеĸ÷ÖÖ¶ÔÏóµÄ״̬£¨Ò²¾ÍÊÇʵÀý±äÁ¿£¬²»ÊÇ·½·¨£©£¬²¢ÇÒ¿ÉÒ԰ѱ£´æµÄ¶ÔÏó״̬ÔÙ¶Á³öÀ´¡£ËäÈ»Äã¿ÉÒÔÓÃÄã×Ô¼ºµÄ¸÷ÖÖ¸÷ÑùµÄ·½·¨À´±£ ´æobject states£¬µ«ÊÇJava¸øÄãÌṩһÖÖÓ¦¸Ã±ÈÄã×Ô¼ººÃµÄ±£´æ ......
ÓÐÐí¶àÈËѧÁ˺ܳ¤Ê±¼äµÄJava£¬µ«Ò»Ö±²»Ã÷°×hashCode·½·¨µÄ×÷Óã¬
ÎÒÀ´½âÊÍһϰɡ£Ê×ÏÈ£¬ÏëÒªÃ÷°×hashCodeµÄ×÷Óã¬Äã±ØÐëÒªÏÈÖªµÀJavaÖеļ¯ºÏ¡£¡¡¡¡
×ܵÄÀ´Ëµ£¬JavaÖеļ¯ºÏ£¨Collection£©ÓÐÁ½À࣬һÀàÊÇList£¬ÔÙÓÐÒ»ÀàÊÇSet¡£
ÄãÖªµÀËüÃǵÄÇø±ðÂð£¿Ç°Õß¼¯ºÏÄÚµÄÔªËØÊÇÓÐÐòµÄ£¬ÔªËØ¿ÉÒÔÖظ´£»ºóÕßÔªËØÎÞÐò£¬µ«ÔªËز» ......
ת×Ô£ºhttp://blog.csdn.net/daijialin/archive/2004/12/27/231384.aspx
ÔÚJDK 1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO API×÷Î ......