• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Thread in Multithreaded Servlet

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic