package com.gemho.meizhou.Util;

import com.gemho.meizhou.service.UploadCloudServiceImp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ThreadUtil extends Thread {

    Logger logger =  LoggerFactory.getLogger(ThreadUtil.class);;

    private UploadCloudServiceImp uploadCloudServiceImp;

    private String name;


    public ThreadUtil() {}

    public ThreadUtil(UploadCloudServiceImp uploadCloudServiceImp, String name) {
        this.uploadCloudServiceImp = uploadCloudServiceImp;
        this.name = name;
    }

    @Override
    public void run() {
        if ("ten".equals(name)) {
            while(true) {

                try{
                    uploadCloudServiceImp.other();
                    // 10分钟采集一次
                    logger.info("=================ten wait==================");
                    Thread.sleep((1000 * 60) * 10);
                }catch(Exception e){
                    e.printStackTrace();
                }

            }
        }else if ("hour".equals(name)) {
            while(true) {
                try{
                    uploadCloudServiceImp.hour();
                    // 10分钟采集一次
                    logger.info("=================one hour wait==================");
                    Thread.sleep((1000 * 60) * 60);
                }catch(Exception e){
                    e.printStackTrace();
                }

            }
        }
    }

}
