itcs3146-project/Job.java

47 lines
1.3 KiB
Java
Raw Normal View History

import java.lang.reflect.Method;
2012-09-28 18:07:28 -04:00
/*
* Author: Bradlee Speice
* Job Class
*
* The purpose of this class is to simulate a running "Job" in memory. To create a new Job, call the
* "start" method, and inform the job of how long it should run, and give it an identifier.
* The job will use this to report back that it is done. If you need to pause the job, you
* can do so. Finally, the job will report back to whoever called it that it needs to be destroyed.
* If there are any questions, email bspeice@uncc.edu
*/
public class Job {
private jobThread myThread; //Reference to the thread we control
private boolean myThreadPaused; //Used to keep track of the execution state of our thread
2012-11-10 10:44:10 -05:00
public Job(int jobTime, int jobID, int jobSize, int beginningLocation, Method parentAlgorithmDeallocate, Object parentAlgorithm ){
2012-09-28 18:07:28 -04:00
//Create a new job, and start it running
2012-11-10 10:44:10 -05:00
myThread = new jobThread(jobTime, jobID,jobSize, beginningLocation, parentAlgorithmDeallocate, parentAlgorithm);
}
public void start(){
2012-09-28 18:07:28 -04:00
myThread.start();
myThreadPaused = false;
2012-09-28 18:07:28 -04:00
}
public void pause(){
if (!myThreadPaused){
myThread.pause();
myThreadPaused = true;
}
}
public void resume(){
if (myThreadPaused){
myThread.jobResume();
myThreadPaused = false;
}
}
public void setBeginningLocation(int newBeginning)
{
myThread.setBeginning(newBeginning);
}
2012-09-28 18:07:28 -04:00
}