• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

static method loading

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I call static method concurrently, How it got executed? Would the caller be given separate instance to that method? or it will wait for getting freed(synchronize)?
Regards,
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since it's a static method, there is no instance to it. Only one exists.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by patil manoj:
Would the caller be given separate instance to that method? or it will wait for getting freed(synchronize)?


There is only one "copy" of both static and regular methods. These are kept in a method area near the classfile - separate from the objects on the heap. An object needs to know it's "type" so that it can locate the method area and find the method that it is to execute.
It is the same for static methods. There is just one "copy" in the method area. If the static method is called more than once at the same time, each caller executes the commands separately and concurrantly in whatever threads they were called from. There is no synchronization unless that is explicitely stated in the code. They just take turns reading the methods commands starting from where they left off last time they had a chance at some scheduler time.
reply
    Bookmark Topic Watch Topic
  • New Topic