package market.thread.rtd2;



import market.tcp.service.RtdEnergyHourService;

import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

public class RtdServletThread extends Thread implements Runnable  {

	private static int runCopies = 0;
	WebApplicationContext _context;
	private RtdEnergyHourService _service1;	  
	
	RtdServletThread() {
		if (++runCopies == 1)
		{
			_context = ContextLoader
					.getCurrentWebApplicationContext();
			_service1 = (RtdEnergyHourService) _context
					.getBean("RtdEnergyHourService"); 
		}
	}

	public void run() {
		while (!RtdServletMgt.getShouldStop()) {
			try {
				//_service1.doInsertRtdHour();
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				try {
					Thread.sleep(10*60*1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
