• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread in Multithreaded Servlet  RSS feed

 
robin singal
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am creating a thread in doPost method
(Reason for creating thread: The process takes a long time as it involves insertion of 10000 or so entries in database)
now there are variables whose values in want in the thread.

Now my question is how do i pass the values of variables to the thread i am creating in the doPost method??
var1 & var2 are the variables whose value i want in the thread.

What i have done to solve the above problem:



Is above the right way to use the variables? When there would be multiple instances running or different users working simultaneouly, would the variables "one" and "two" will be shared among them as they(one & two) are class variables.

Thanks
 
Bosun Bello
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those variables are local to the method they are in. So each request thread will have its own copy.
 
robin singal
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those variables are local to the method they are in.


Can you please elaborate a bit ...? The method you are considering is doPost() & the variables considered is one & two ??

Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!