• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

threads and static methods

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class RequestProcessor
{
public static void handleRequest(Request r)
{
//perform operations on r using variables local to handleRequest method
}
}
if i had multiple threads each with their own Request object calling RequestProcessor.handleRequest(request) simultaneously would there be threading issues or threads conflicting? Would there be any benefit making handleRequest a synchronized method?
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Edward Farrow:
class RequestProcessor
{
public static void handleRequest(Request r)
{
//perform operations on r using variables local to handleRequest method
}
}
if i had multiple threads each with their own Request object calling RequestProcessor.handleRequest(request) simultaneously would there be threading issues or threads conflicting? Would there be any benefit making handleRequest a synchronized method?


Hi, I think if the data and objects in a method are part of the thread context you wouldn't need to use mutual exclusion or locks. In this case request is thread specific so you shouldn't have to. However you could synchronize on objects within methods that are global (visible to other threads) and problems of concurrancy exist, ie only one thread should be allowed to excecute the critical section on these objects at one time.
Ratna.
 
reply
    Bookmark Topic Watch Topic
  • New Topic