I am Using Quarts Scheduler for job scheduling. I have various jobs which gets medical report of different users daily and send that report to individual user. Each job has a specific user associated with it. 
Before each job starts executing its business logic the JobListener implementation class creates an instance of the class UserJobExecution.

```
public class UserJobExecution 
{  
   static ThreadLocal currentExecution = new ThreadLocal()  
   User user;  
   static UserJobExecution getCurrent(){  
     (UserJobExecution ) currentExecution.get();  
   }  
   UserJobExecution(String jobName){  
     try  
     {  
       user = getUserFromDB(jobName);  
     }   
     catch(e)  
     {  
       e.printStackTrace();  
     }  
   }  
   User getUser(){  
      return user;  
   }  
   //rest of the code  
}  

class WebServiceUtil{  
   static HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager());  
   User user;  
   WebServiceUtil(User user){  
     this.user = user;  
   }  
   static WebServiceUtil getDefaultWs(){  
     UserJobExecution userJobExecution = UserJobExecution.getCurrent();  
     return (new WebServiceUtil(userJobExecution.getUser()));  
   }  
   static execute(String request){  
     getDefaultWs().executeService(request);  
   }  

}  

```

Both the above classes has a User object that has two fields username and password. 
Every job makes a call to a common webservice by calling its executeMethod with its own user name and password to get medical report associated to a particular user. 
The webservice takes time to process a report. So first a job requests for a report and gets a report Id and then the job continuously calls the webservice for retrieving that report every 15 secs till webservice processes the report and the job gets the report. 

The issue i am facing is that if there are multiple jobs triggered at the same time then it messes up the username and password.(The above getCurrent() method is called to get the currently executing job)

I am creating a single instance of UserJobExecution for every job. The method jobToBeExecuted is called by the Scheduler for every Job before it is executed.

```
public class ExecutionJobListener implements JobListener {
  public void jobToBeExecuted(JobExecutionContext context){
    //Other code
    UserJobExecution userJobExecution = new UserJobExecution(job)
    userJobExecution.save()
  }
//Rest of the code
}

```