package com.ms.biz.listener;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

//@Component
public class JobListener implements ApplicationListener<ContextRefreshedEvent>, Runnable {

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        JobListener listener = event.getApplicationContext().getBean(JobListener.class);
        new Thread(this).start();
    }

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("run run run...");
        }
    }
}