1

I am not sure I am on the right track or not. In my application jdbc connection is created and some process calls commit over that transaction. In the same flow, a thread is created and again call the same process to perform commit. But the later commit is not committing correct user data in WHO columns. WHO columns need to take its values from user session. I have checked that if i dont create thread and directly call the process then WHO columns are updating correctly. On thread creation, issue arising. Application is created using adf model. plz suggest how to pass user context to thread.

user3395103
  • 131
  • 1
  • 3
  • 13

3 Answers3

2

Unless you post the code, it's hard to answer your questions. But based on you wordings, I think you are having difficulty passing some variable/data to threads. The easiest and most simple way is to use constructors. When you are creating an object to call the class implementing/extending the thread class, pass the data as parameters. Then use a constructor in the called class to get the values and use them as needed. I hope that helps and was in accordance to the question you asked.

Govind Madhu
  • 182
  • 1
  • 9
0

you can pass the data to thread using a class with getter and setter method, set all the data by creating object before starting thread and using getter method you can get it in the thread..!

 public Class  NormalClass
{ 
     int data = 0;
     public void setData(int a)
   {
       this.a = a;
    }
    public int getData(int a)
   {
     return this.a;
   }    
}

Before starting thread set data in class, then in run method you can access it

Shailesh
  • 657
  • 2
  • 13
  • 27
0

You can use ThreadLocal to maintain some context related to the current thread, You can get more information on Usage of ThreadLoacal

Community
  • 1
  • 1
ravthiru
  • 8,878
  • 2
  • 43
  • 52