易截截图软件、单文件、免安装、纯绿色、仅160KB

quartz一分钟教程 java任务调度

 quartz是干啥的? 任务调度用的
任务调度是干啥的?就是在预定的时间做预定的事
1.在quart网站下最新的JAR包
2.建个项目,把quartz的JAR包加入到项目
3.新建一个任务
public class MyJob implements org.quartz.Job {
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
System.out.println("我被调用了");
}

}

4.开启任务:
public class StartSchedule {
public static void main(String[] args) throws Exception {
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sched = sf.getScheduler();
JobDetail job = new JobDetail("job1", "group1", MyJob.class);
CronTrigger t = new CronTrigger("trigger1", "group1", "job1", "group1", "0/2 * * * * ?");
sched.scheduleJob(job, t);
sched.start();
Thread.sleep(500000);
sched.shutdown(true);
}
}

5.运行StartSchedule即可
其中:
"0/2 * * * * ?" 是cronExpression表达式
一共有7组数据组成,位与位之间用空间分隔
分别代表  “秒 分 时 日 月 周 年” 其中年是可以省略的,所以在例子中用了6组
官方的例子:
Examples
Here are some full examples:
Expression
Meaning
0 0 12 * * ?

Fire at 12pm (noon) every day
0 15 10 ? * *

Fire at 10:15am every day
0 15 10 * * ?

Fire at 10:15am every day
0 15 10 * * ? *

Fire at 10:15am every day
0 15 10 * * ? 2005

Fire at 10:15am every day during the year 2005
0 * 14 * * ?

Fire every minute starting at 2pm and ending at 2:59pm, every day
0 0/5 14 * * ?

Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day
0 0/5 14,18 * * ?

Fire every 5 minutes starting at 2pm and
ending at 2:55pm, AND fire every 5 minutes starting at 6pm and ending
at 6:55pm, every day
0 0-5 14 * * ?

Fire every minute starting at 2pm and ending at 2:05pm, every day
0 10,44 14 ? 3 WED

Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.
0 15 10 ? * MO


相关文档:

java经典题目

 
 
楼主发表于:2008-06-17 15:26:20
l    JBS
1.列举出 10个JAVA语言的优势
a:免费,开源,跨平台(平台独立性),简单易用,功能完善,面向对象,健壮性,多线程,结构中立,企业应用的成熟平台, 无线应用
2.列举出JAVA中10个面向对象编程的术语
a:包,类,接口,对象,属性,方法,构造器 ......

php和java关于目录树(列出某一目录下文件结构)

java的写法
/**
*
* @param location
* @param nameList保存结果的!
*/
public void listDict(String location, List<String> nameList) {
File fileList = new File(location);
if (fileList.isDirectory()) {
File[] files = fileList.listFiles();
for (File f : files) {
i ......

JAVA中的依赖倒原则

JAVA中的依赖倒原则
美国法律有一条最基本的准则就是“人人平等”,我们不去管它是经过什么样的斗争、什么样的流血牺牲换来的,只把它理解为一个JAVA方法,该方法定义如下:
    public final boolean 人人平等(人1,人2){
       return true;
  &n ......

Java通用验证码程序及应用示例(提供源码文档下载)

把之前项目中写的一个Java通用验证码程序整理了一下,与大家分享,希望能抛砖引玉。
一、主要功能:
1、支持纯数字、大写字母、小写字母,及两两混合或三者混合类型验证码;
2、支持自定义特殊字符排除(如0oOi1jI);
3、支持图片及文字两种类型验证码;
4、支持自定义验证码图片大小;
5、支持自定义干扰线条数;
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号