亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

正在回答

1 回答

package?com.may.seventy;

import?java.text.SimpleDateFormat;
import?java.util.Calendar;
import?java.util.TimerTask;

/**
?*?Created?by?junfeng?on?17/5/17.
?*/
public?class?MyTimerTask?extends?TimerTask?{

????private?String?name;
????public?MyTimerTask(String?inputName){
????????name?=?inputName;
????}

????@Override
????public?void?run()?{
????????Calendar?calendar?=?Calendar.getInstance();
????????SimpleDateFormat?sf?=?new?SimpleDateFormat("yyyy-MM-dd?HH:mm:ss");
????????System.out.println("Current?exec?name?is:"+name);
????}

????public?String?getName()?{
????????return?name;
????}

????public?void?setName(String?name)?{
????????this.name?=?name;
????}
}
package?com.may.seventy;

import?java.text.SimpleDateFormat;
import?java.util.Calendar;
import?java.util.Timer;

/**
?*?Created?by?junfeng?on?17/5/17.
?*/
public?class?MyTimer?{


????public?static?void?main(String[]?args)?{
????????Timer?timer?=?new?Timer();
????????MyTimerTask?myTimerTask?=?new?MyTimerTask("NO.1");
????????//timer.schedule(myTimerTask,1000L,5000l);



????????Calendar?calendar?=?Calendar.getInstance();
????????SimpleDateFormat?sf?=?new?SimpleDateFormat("yyyy-MM-dd?HH:mm:ss");
????????System.out.println(sf.format(calendar.getTime()));

????????calendar.add(Calendar.SECOND,3);

//????????myTimerTask.setName("test1");
//????????timer.schedule(myTimerTask,calendar.getTime());


//????????myTimerTask.setName("test2");
//????????timer.schedule(myTimerTask,calendar.getTime(),3000);



????????myTimerTask.setName("test3");
????????timer.schedule(myTimerTask,2000);

????}

}


1 回復 有任何疑惑可以回復我~
#1

慕的地6384686 提問者

非常感謝!
2017-05-17 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

有源碼嗎?

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號