import java.awt.AWTException;
import java.awt.Robot;

public class AllocatetaskThread  extends Thread 
{

	
	private SeverList serverlist_list = null;
	private TaskList tasklist_list = null;

	Robot  r   =   null;
	 
	public AllocatetaskThread(SeverList serverlist)
	{
		this.serverlist_list=serverlist;
	}
	
	public   void run() 
	{
		
		try {
			 r= new   Robot(); 
			//循环处理，直到为空
			while(tasklist_list.getNext() != null)
			{
				
			
				while (  serverlist_list.rest_Memory < tasklist_list.get_need_Memory())
					{   
						r.delay(10);
				 }
				serverlist_list.syntask.reduce_memory(serverlist_list, tasklist_list);
						
				Thread.sleep(tasklist_list.get_time());
						
						//serverlist_list.lock.lock();
						
				serverlist_list.syntask.add_memory(serverlist_list, tasklist_list);
						
						//serverlist_list.lock.unlock();
						
				System.out.println("异常节点-执行完成："+tasklist_list.get_taskName());
						
			}		
			//保证连头不变，并去掉一个任务
			serverlist_list.importTask.setNext(null);
	
			serverlist_list.isDispose = true;
			
			//线程自带自杀自己
			this.interrupt();
			
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (AWTException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	


}


































