Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. private final ExecutorService scheduler = Executors.newCachedThreadPool();
  2.  
  3. public void startJob(Job job, List <Object> objectList) {
  4. //Store the results of this in a map using a future and the id of job??
  5. scheduler.submit(jobThreadInterface.create(job, objectList));
  6. }
  7.  
  8. public class ClassB implements Runnable{
  9.  
  10. private Job job;
  11. private List <Object> objectList;
  12. private int changeSleepDuration;
  13.  
  14. public ClassB (Job job, List <Object> objectList){
  15. this.job = job;
  16. this.objectList= objectList;
  17. }
  18.  
  19. public void run() {
  20. //It will keep looping through this sleep command until there are no more objects left...
  21. for (Object object : objectList){
  22. if (object.getSleepNumber() > 0){
  23. Thread.sleep(object.getSleepNumber() + changeSleepDuration);
  24. }
  25. }
  26.  
  27. public setChangeSleepDuration(int i){
  28. changeSleepDuration = i;
  29. }
  30. }
  31. }
  32.  
  33. ClassB runnable = jobThreadInterface.create(job, objectList);
  34. list.add(runnable);
  35. scheduler.submit(runnable);
  36.  
  37. list.get(0).setChangeSleepDuration(1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement