Java¶¨Ê±Æ÷
ÔÚÓ¦Óÿª·¢ÖУ¬¾³£ÐèҪһЩÖÜÆÚÐԵIJÙ×÷£¬±ÈÈçÿ5·ÖÖÓÖ´ÐÐijһ²Ù×÷µÈ¡£ÔÚWEBÏîÄ¿ÖпÉÄÜÐèҪÿ¸ôÒ»¶Îʱ¼ä×Ô¶¯Éú³É¾²Ì¬Ò³£¬×Ô¶¯¼ì²âÊÇ·ñÓÐÐÂÓʼþ£¬¶¨Ê±×Ô¶¯±¸·ÝÎļþµÈ²Ù×÷¡£ÕâЩ¶¼¿ÉÒÔͨ¹ý¶¨Ê±Æ÷TimerÀ´½â¾ö¡£
ÕâÀï½öÌṩ¶¨Ê±Æ÷µÄ²¿·Ö·½·¨ºÍ˵Ã÷£¬¾²Ì¬Ò³Éú³ÉµÈ²Ù×÷¶ÁÕß¿ÉÒÔͨ¹ýÏà¹Ø·½·¨×ÔÐнâ¾ö¡£
¡£¡£¡£°Ù¶È¿Õ¼äÌù´úÂë×ÜÊǺÜÈÃÈËÍ·ÌÛ£¬ÅźõĴúÂëÄõ½ÕâÀï¾Í³öÏÖ»ìÂÒ¡£
(1)Timer.schedule(TimerTask task,Date time)°²ÅÅÔÚÖƶ¨µÄʱ¼äÖ´ÐÐÖ¸¶¨µÄÈÎÎñ¡£
(2)Timer.schedule(TimerTask task,Date firstTime ,long period)°²ÅÅÖ¸¶¨µÄÈÎÎñÔÚÖ¸¶¨µÄʱ¼ä¿ªÊ¼½øÐÐÖظ´µÄ¹Ì¶¨ÑÓ³ÙÖ´ÐУ®
(3)Timer.schedule(TimerTask task,long delay)°²ÅÅÔÚÖ¸¶¨ÑÓ³ÙºóÖ´ÐÐÖ¸¶¨µÄÈÎÎñ£®
(4)Timer.schedule(TimerTask task,long delay,long period)°²ÅÅÖ¸¶¨µÄÈÎÎñ´ÓÖ¸¶¨µÄÑÓ³Ùºó¿ªÊ¼½øÐÐÖظ´µÄ¹Ì¶¨ÑÓ³ÙÖ´ÐУ®
(5)Timer.scheduleAtFixedRate(TimerTask task,Date firstTime,long period)°²ÅÅÖ¸¶¨µÄÈÎÎñÔÚÖ¸¶¨µÄʱ¼ä¿ªÊ¼½øÐÐÖظ´µÄ¹Ì¶¨ËÙÂÊÖ´ÐУ®
(6)Timer.scheduleAtFixedRate(TimerTask task,long delay,long period)°²ÅÅÖ¸¶¨µÄÈÎÎñÔÚÖ¸¶¨µÄÑÓ³Ùºó¿ªÊ¼½øÐÐÖظ´µÄ¹Ì¶¨ËÙÂÊÖ´ÐУ®
ϱßдһ¸ö¼òµ¥µÄ²âÊÔÀࣺ
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(), 1000, 2000);//ÔÚ1ÃëºóÖ´ÐдËÈÎÎñ,ÿ´Î¼ä¸ô2Ãë
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("ÎÒÊÇÀ´²âÊԵġ£¡£ÎÒÁ½Ãë³öÀ´Ò»´Î");
}
}
}
ÕâÑù£¬Ã¿¸ôÁ½ÃëÖӾͻáÔÚ¿ØÖÆ̨Êä³öÓï¾ä¡£
ϱß˵϶¨Ê±Æ÷ÔÚJSPÖеÄÓ¦Óá£ÔÚJSPÖпÉÒÔ¿¿¼àÌýÆ÷ºÍ¶¨Ê±Æ÷µÄ½áºÏÀ´½â¾öijЩÎÊÌâ¡££¨SpringÌṩ¶¨Ê±Æ÷µÄ¸ß¼¶ÊµÏÖ¶ÁÕß¿ÉÒÔÖ´ÐÐÑо¿£¬ÕâÀïÕâ˵һ¸ö¼òµ¥µÄʵÏÖ¡££©
ÏÈÀ´Ò»¸ö¶¨Ê±Æ÷µÄÈÎÎñ£º
package com.kanba.init;
import java.util.Date;
import java.ut
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
ÒªÀíÀà¼ÓÔØÌåϵ½á¹¹£¬¾Í±ØÐëÇå³þÈçϼ¸µã±È½Ï»ù±¾µÄÔÔò:
1. classLoaderÊÇÒ»ÖÖ¸¸×ÓÊ÷Ðνṹ£¨×¢£ºÕâÀï²»ÊÇÖ¸Àà¼Ì³ÐµÄ¸¸×Ó¹Øϵ£©
2. ¸¸classLoaderÎÞ·¨¿´µ½×ÓclassLoader¼ÓÔصÄÀà
3¡¢ÐéÄâ»ú×ñÊØË«Ç×ίÍмÓÔØÔÔò£¬¼´ÈκÎ×ÓclassLoaderÐëÊ×ÏÈίÍи¸classLoaderÏȼÓÔØÐèÒªµÄÀ࣬µ±¸¸classLoader¼ÓÔز»µ½Ê±ÔÙÓÉ×ÓclassLoa ......
ÏÂÃ濪½²¹ÊÊ£º
´ÓÇ°Óиö·¿¼ä£¬·¿¼äÀïÓзÝÎĵµ£¬·¿¼ä»¹ÓÐÒ»°ÑÔ¿³×¡£ Õâ°ÑÔ¿³×ÔÚÕÅÈýÊÖÀï¡£
ÕâʱÀîËÄÀ´ÏòÕÅÈýÒªÄÇ·ÝÎĵµ¡£ ÕÅÈý²»Ì«Ï²»¶ÀîËÄ£¬µ«ÓÖŵ¢ÎóÁË
¹¤×÷²»ºÃ½»´ú¡£ÓÚÊÇÕÅÈý¾Í°Ñ·¿¼äÀïÎĵµµÄÎĵµ¸´Ó¡ÁËÒ»·Ý£¬È»ºó°ÑÄǸö¸´Ó¡¼þ½»¸øÁËÀîËÄ£¨Õâ½Ð´«Öµ£©¡£
ÀîËÄÄõ½Îĵµºó£¨¸´Ó¡¼þ£©£¬ºúÂÒÐÞ¸ÄÒ» ......
£¨×¢£ºÇ°ÃæдÁËÒ»¸ö³¬´óÕûÊýÏà¼ÓµÄÀ࣬²Î¼û£º ³¬´óÕûÊýÏà¼Ó£¬³¬¹ýÁËlongµÄ·¶Î§£¬ÄãÒªÔõô×ö£¡£¬ºóÀ´ÓÐÅóÓÑÆÀÂÛ˵BigDecimal¿ÉÒÔÍêȫʵÏÖÎÒµÄÕâÕâ¸ö¹¦ÄÜ£¬¸Õ¿ªÊ¼µÄʱºò£¬ÎÒ»¹²»·þÆø£¬¾ÝÎÒËùÖªÄÇÀïÓÐÕâÑùµÄÀàŶ£¬ºóÀ´±¨×Å˵·þËûµÄÐÄÀíÈ¥ÕÒÁËһϣ¬ºÇºÇ£¬½á¹û¾ÓÈ»×Ô¼º±»Ëµ·þÁË£¬È·ÊµÓÐÕâôһ»ØÊ£¬ÀûÓÃBigDecimal²Ù×÷³¬´óÕûÊýÒ ......