/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  org.springframework.beans.factory.annotation.Autowired
 *  org.springframework.context.annotation.Bean
 *  org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
 *  org.springframework.web.context.WebApplicationContext
 */
package com.hst.task.scuduler;

import com.hst.framework.constants.WebConstants;
import com.hst.task.runable.TestSjts;
import com.hst.task.support.ScheduledMethodRunnable;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.web.context.WebApplicationContext;

public class TestJob {
    @Autowired
    private ThreadPoolTaskScheduler threadPoolTaskScheduler;

    @Bean
    public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
        ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
        scheduler.setPoolSize(20);
        scheduler.setThreadNamePrefix("task-");
        return scheduler;
    }

    public void job1() throws InterruptedException {
        System.out.println(new Date());
        Thread current = Thread.currentThread();
        System.out.println(Thread.activeCount());
        System.out.println(current.getId());
        System.out.println("jobsTest1" + new Date().getTime());
    }

    public void job2() throws InterruptedException, NoSuchMethodException {
        System.out.println("\u521d\u59cb\u5316" + this.threadPoolTaskScheduler.getScheduledExecutor());
        this.threadPoolTaskScheduler.initialize();
        System.out.println(this.threadPoolTaskScheduler.getScheduledExecutor());
        long currentTime = System.currentTimeMillis();
        Date nextTime = new Date(currentTime + 10000L);
        WebApplicationContext webApplicationContext = WebConstants.WEB_APP_CONTEXT;
        new ScheduledMethodRunnable(webApplicationContext.getBean("testJob"), "job1");
        Object[] args = new Object[]{"name1", "id1"};
        System.out.println("\u5f00\u59cb\u4fee\u6539 " + new Date());
        ScheduledMethodRunnable runnable2 = new ScheduledMethodRunnable(new TestSjts(), "testThread", args);
        this.threadPoolTaskScheduler.schedule((Runnable)runnable2, nextTime);
        Object[] args2 = new Object[]{"name2", "id2"};
        ScheduledMethodRunnable runnable3 = new ScheduledMethodRunnable(new TestSjts(), "testThread", args2);
        this.threadPoolTaskScheduler.schedule((Runnable)runnable3, nextTime);
        Object[] args3 = new Object[]{"name3", "id3"};
        ScheduledMethodRunnable runnable4 = new ScheduledMethodRunnable(new TestSjts(), "testThread", args3);
        this.threadPoolTaskScheduler.schedule((Runnable)runnable4, nextTime);
        Object[] args4 = new Object[]{"name4", "id4"};
        ScheduledMethodRunnable runnable5 = new ScheduledMethodRunnable(new TestSjts(), "testThread", args4);
        this.threadPoolTaskScheduler.schedule((Runnable)runnable5, nextTime);
        System.out.println("\u5df2\u7ecf\u4fee\u6539cron" + new Date());
        System.out.println(this.threadPoolTaskScheduler.getScheduledExecutor());
    }

    public static void main(String[] args) throws NoSuchMethodException, InterruptedException {
        new TestJob().job2();
    }
}
