package market.thread.AutoJudge;

import market.Qms.qcm.service.QcmJhyPhyresultService;
import market.Qms.qcm.service.QcmJudgePhysicalService;

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

class AutoJudgeThread extends Thread implements Runnable {
	private static int runCopies = 0;
	WebApplicationContext _context;
	private QcmJudgePhysicalService _service1;
	private QcmJhyPhyresultService _service2;
	  
	
	AutoJudgeThread() {
		if (++runCopies == 1)
		{
			_context = ContextLoader
					.getCurrentWebApplicationContext();
			_service1 = (QcmJudgePhysicalService) _context
					.getBean("QcmJudgePhysicalService"); 
			_service2 = (QcmJhyPhyresultService) _context
					.getBean("QcmJhyPhyresultService"); 
		}
	}

	public void run() {
		while (!AutoJudgeMgt.getShouldStop()) {
			try {
				//_service1.autoJudge();//综合判定
				//_service2.AutoJudge();
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				try {
					Thread.sleep(3*60*1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
