Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

执行Tasks.depose后定时器还在运行 #638

Closed
scchenyong opened this issue May 4, 2014 · 4 comments
Closed

执行Tasks.depose后定时器还在运行 #638

scchenyong opened this issue May 4, 2014 · 4 comments
Milestone

Comments

@scchenyong
Copy link

RT

@zozoh
Copy link
Member

zozoh commented Jun 25, 2014

你调用代码是怎么写的?
我的测试代码:

public static void main(String[] args) throws Exception {
    Tasks.scheduleAtFixedRate(new Runnable() {
        public void run() {
            System.out.println("run : " + Times.sDTms2(Times.now()));
        }
    }, 2);
    Thread.sleep(10000);
    Tasks.depose();
}

输出:

ALL Nutz Log via Log4jLogAdapter
 INFO:[main]: Nutz is licensed under the Apache License, Version 2.0 .
Report bugs : https://github.com/nutzam/nutz/issues
run : 14-06-25 17:23:39.222
run : 14-06-25 17:23:41.199
run : 14-06-25 17:23:43.199
run : 14-06-25 17:23:45.200
run : 14-06-25 17:23:47.199
run : 14-06-25 17:23:49.200
 INFO:[main]: Tasks stopping. Tasks awaiting execution: 0

@scchenyong
Copy link
Author

测试情况

      public static void main(String[] args) {
        Date nextDay = Dates.addDay(new Date(), 1);
        Tasks.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                System.out.println(123);
            }
        }, nextDay, 1, TimeUnit.DAYS);
        Lang.quiteSleep(2000);
        Tasks.depose();
    }

使用时是在服务启动时加载部分任务计划,停止服务时常规操作退不掉。
我现在是执行System.exit(0);完全退出的。

@zozoh
Copy link
Member

zozoh commented Jun 30, 2014

哦,因为最终是调用 java.util.concurrent.ScheduledThreadPoolExecutor
那个东西,好像必须是先执行过一次,才能被停止的

@qinerg 有空关注一下这个问题哦 (fccb6e0)

@qinerg
Copy link
Member

qinerg commented Jul 19, 2014

刚看到,我看一下

wendal added a commit that referenced this issue Jul 23, 2014
@wendal wendal closed this as completed Jul 23, 2014
@wendal wendal added this to the 1.b.51 milestone Jul 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@zozoh @wendal @qinerg @scchenyong and others