Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private final ExecutorService scheduler = Executors.newCachedThreadPool();
- public void startJob(Job job, List <Object> objectList) {
- //Store the results of this in a map using a future and the id of job??
- scheduler.submit(jobThreadInterface.create(job, objectList));
- }
- public class ClassB implements Runnable{
- private Job job;
- private List <Object> objectList;
- private int changeSleepDuration;
- public ClassB (Job job, List <Object> objectList){
- this.job = job;
- this.objectList= objectList;
- }
- public void run() {
- //It will keep looping through this sleep command until there are no more objects left...
- for (Object object : objectList){
- if (object.getSleepNumber() > 0){
- Thread.sleep(object.getSleepNumber() + changeSleepDuration);
- }
- }
- public setChangeSleepDuration(int i){
- changeSleepDuration = i;
- }
- }
- }
- ClassB runnable = jobThreadInterface.create(job, objectList);
- list.add(runnable);
- scheduler.submit(runnable);
- list.get(0).setChangeSleepDuration(1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement