- 浏览: 121408 次
- 性别:
- 来自: Singapore
文章分类
- 全部博客 (112)
- Tiger Thread (18)
- Perforce (6)
- Spring (5)
- maven (3)
- log4j (3)
- Quartz Scheduler (4)
- unix and linux (12)
- hibernate (3)
- Enum (1)
- Futures and Options (1)
- Market Making (2)
- Java Basic (11)
- Tibco EMS (3)
- F I X message (5)
- equity derivative (2)
- Sybase (3)
- XML (1)
- JUnit (2)
- J A X B 2.0 (1)
- N I O (1)
- windows batch file (1)
- Cruise Control (1)
- util Class (5)
- ant (1)
- JMS (1)
- profiling (0)
- Sql Server (6)
- GXT (2)
- eclipse (1)
- Generics (1)
- Tibco RV (3)
- Autosys (0)
- Message (1)
最新评论
-
houzhe11:
<property name="proxyTa ...
AOP usage -- BeanNameAutoProxyCreator usage
Executor can return Executor, ExecutorService, and ScheduledExecutorService.
This is very, very usful Tiger new timer.
scheduler.scheduleAtFixedRate(new TimePrinter(System.out), 0, 10, SECONDS);
4 arguments:
1) Runable or Callable, which is the task scheduled to run.
2) 0. When the first time to run. 0 seconds later, means, immediately.
3) 10. When next time run. 10 seconds later.
4) What's time unit. The argument 0, and 10, all use the time unit SECONDs.
package test;
import java.io.PrintStream;
import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import static java.util.concurrent.TimeUnit.SECONDS;;
public class Thread5
{
public static void main(String[] args)
{
// Get the scheduler
//An alternative way to get scheduler is like this, you can simply replace with it
//ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(10);
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
// Get a handle, starting now, with a 10 second delay
final ScheduledFuture<?> timeHandle = scheduler.scheduleAtFixedRate(new TimePrinter(System.out), 0, 10, SECONDS);
// Schedule the event, and run for 1 hour (60 * 60 seconds)
scheduler.schedule(new Runnable()
{
public void run()
{
timeHandle.cancel(false);
}
}, 60 * 60, SECONDS);
}//end of main
}
class TimePrinter implements Runnable
{
private PrintStream out;
public TimePrinter(PrintStream out)
{
this.out = out;
System.out.println("a TimePrinter instance is created");
}
public void run()
{
out.printf("Current time: %tr%n", new Date());
}
}
Summary:
Step 1) Get a ScheduledExecutorService --- Scheduler
Step 2) Tell the scheduler, which to run, how frequent, when to start. ---generate ScheduledFuture
Step 3) Start the Scheduler using schedule() method, wraping ScheduledFuture into Runnable, passing the Runnable to the schedule()
发表评论
-
javadoc for Cyclic Barrier
2009-04-24 12:48 848java.util.concurrent.CyclicBarr ... -
Delayed interface and Delay Queue
2009-04-22 17:42 1000/** * A standard implementati ... -
Count Down Latch example code
2009-04-22 10:38 1089Key point : 1) 1 task is co ... -
3 ways to break dead lock
2009-04-21 17:30 7031) supply special resources. ... -
Blocking Queue Usage
2009-04-20 11:21 7953 implementations: LinkedBlocki ... -
The usage of Lock and Condition
2009-04-18 12:31 1038//: concurrency/waxomatic2/WaxO ... -
Re entrantLock usage
2009-04-15 17:15 1290a thread can be really interru ... -
new interrupt in java5
2009-04-15 12:08 634In Java 5, Thread.interrupt() i ... -
interrupt
2009-04-15 10:57 7641) Each thread has a boolean in ... -
Executor Service Usage
2009-04-14 18:18 861ExecutorService exec = Executor ... -
Thread Local usage
2009-04-14 17:46 760ThreadLocal usage – from Javado ... -
Timer TimerTask usage
2009-04-14 12:03 688Timer typical usage new Tim ... -
wait, notify及线程通讯机制
2009-02-26 22:42 8041) wait(), notify() 方法被调用的时候,只要 ... -
Java Thread programming basical knowledge
2009-02-26 22:40 926yield() : Give a hint to the th ... -
Count Down Latch explanation
2008-10-02 10:29 897Very important paragraph on how ... -
Executor usage
2008-07-22 11:04 843Executor is used to arrange thr ... -
Callable Usage
2008-07-22 10:24 884The important thing need to loo ...
相关推荐
Scheduled-executor:一个简单的golang库,用于模拟Java中著名的调度线程池执行程序
spring boot @scheduled注解 cron 表达式实现计划任务调度。
Spring的任务调度@Scheduled注解——task:scheduler和task:executor的解析,做了一些测试说明了各个参数的作用
预定服务 一个简单的项目,可以帮助我创建必须使用Windows Task Scheduler运行的任务的jar文件。 有可能的使用 创建一个可执行的jar文件,然后从... for(Service service : services) { service.start(); }
IDEA使用springboot自带scheduled实现任务调度 代码解析:https://www.cnblogs.com/personblog/p/14237202.html
开发目的:因为每月的月底需要提交 考勤表 担心忘记提交 ...使用技术:scheduled 线程池定时循环 使用 socket发送Email(无需email Jar包发送邮件) 重要配置文件:pwd.properties 其中要填写好 邮箱 和 邮箱密码 等信息
spring @Scheduled定时任务代码
标签:archiva-scheduled-1.2.jar,archiva,scheduled,1.2,jar包下载,依赖包
标签:archiva-scheduled-1.3.2.jar,archiva,scheduled,1.3.2,jar包下载,依赖包
标签:archiva-scheduled-1.0.2.jar,archiva,scheduled,1.0.2,jar包下载,依赖包
标签:archiva-scheduled-1.1.jar,archiva,scheduled,1.1,jar包下载,依赖包
使用spring @Scheduled注解执行定时任务
在不停服务的情况下,动态修改Spring定时任务的执行周期,即动态修改定时任务的cron参数。
标签:archiva-scheduled-1.0-javadoc.jar,archiva,scheduled,1.0,javadoc,jar包下载,依赖包
标签:archiva-scheduled-1.3.6-javadoc.jar,archiva,scheduled,1.3.6,javadoc,jar包下载,依赖包
NULL 博文链接:https://rmn190.iteye.com/blog/273564
@scheduled任务调度使用详解及@scheduled与多线程和@Async异步任务结合使用
本文将详细探讨Spring Boot中@Scheduled注解的使用,包括其原理、实现流程、步骤和代码示例。通过本文,读者将能够了解如何在Spring Boot应用中轻松创建和管理定时任务。 # @Scheduled注解简介 在Spring框架中,@...
本工程用于研究如何在Spring框架中采用Scheduled注释的方式实现Spring定时器的功能 本工程编码方式:UTF-8 相关博客:http://blog.csdn.net/gaohuanjie/article/details/43559167
Swift-定时器scheduledTimer