diff --git a/src/main/java/org/etsi/osl/metrico/services/JobService.java b/src/main/java/org/etsi/osl/metrico/services/JobService.java index 17b96fcbf6115c52e00179f5984a15aec5485427..635d5e0854c5df701172ead359faa9afc370bd66 100644 --- a/src/main/java/org/etsi/osl/metrico/services/JobService.java +++ b/src/main/java/org/etsi/osl/metrico/services/JobService.java @@ -43,7 +43,7 @@ public class JobService { * @throws IllegalArgumentException if the job's start or end date is invalid * @throws RejectedExecutionException if the job could not be scheduled */ - public Job startJob(Runnable task, Job job) { + public synchronized Job startJob(Runnable task, Job job) { logger.debug("Starting Job for MeasurementCollectionJob with ID {}.", job.getMeasurementCollectionJobRef()); MeasurementCollectionJobMVO mcjMVO = new MeasurementCollectionJobMVO(); @@ -89,7 +89,7 @@ public class JobService { * * @param job the job to be stopped */ - public void stopJob(Job job) { + public synchronized void stopJob(Job job) { MeasurementCollectionJobMVO mcjMVO = new MeasurementCollectionJobMVO(); @@ -128,7 +128,7 @@ public class JobService { * * @param measurementCollectionJobUuid the UUID of the Measurement Collection Job */ - public void stopJob(String measurementCollectionJobUuid) { + public synchronized void stopJob(String measurementCollectionJobUuid) { Job job = runningJobs.get(measurementCollectionJobUuid); if (job != null) { stopJob(job); @@ -142,7 +142,7 @@ public class JobService { * * <p>This method iterates over all jobs in the runningJobs map, stops each job, and then clears the map.</p> */ - public void stopAllJobs() { + public synchronized void stopAllJobs() { for (Job job : runningJobs.values()) { stopJob(job); }