import java.util.Date; public class Critic { class clock implements Runnable{ public void run() { Date today = new Date(); if(today.toString().indexOf("01:18:")!=-1) {
public void Test(){ Thread time1 = new Thread(new clock()); time1.start(); } public static void main(String[] args) {
new Critic().Test();
} }
import java.util.Date; public class Critic { class clock implements Runnable{ public void run() { Date today = new Date(); if(today.toString().indexOf("01:18:")!=-1) {
public class Critic {
class clock implements Runnable{ public void run() {
Date today = new Date();
if(today.toString().indexOf("01:18:")!=-1)
{
doSomeThing();
}
else
{
try {
Thread.currentThread().sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
}
} private void doSomeThing() {
System.out.println("a;sljd;lasjdf;lasjd;flasj;d");
}
}
public void Test(){
Thread time1 = new Thread(new clock());
time1.start();
}
public static void main(String[] args) {
new Critic().Test();
}
}
public class Critic {
class clock implements Runnable{ public void run() {
Date today = new Date();
if(today.toString().indexOf("01:18:")!=-1)
{
doSomeThing();
}
else
{
try {
Thread.currentThread().sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
}
} private void doSomeThing() {
System.out.println("a;sljd;lasjdf;lasjd;flasj;d");
}
}
public void Test(){
Thread time1 = new Thread(new clock());
time1.start();
}
public static void main(String[] args) {
new Critic().Test();
}
}
http://www.opensymphony.com/quartz/Quartz可以使用Cron表达式灵活地控制任务运行的起始时间和间隔。