• 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

Class.forName Thread Safe ?

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following code, it does a Class.forName based on the content-type of a particular attachment. So far so good.... I have few questions, Please answer at your convenience .





1) If the same application is being accessed by multiple threads simultaneoulsy, will this cause a problem

2) Will the package org.buddy.deadlock be loaded every time it calls class.forName ?. Is this a performance hit ?

3) Also if the underlying classes in the org.buddy.deadlock package are dependent on third-party applications will they also be loaded with the call to class.forName ?.

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1) If the same application is being accessed by multiple threads simultaneoulsy, will this cause a problem


That depends on what constitutes a "problem". As it is, the code may return an object that does not belong to the mimetype that's been passed in.

2) Will the package org.buddy.deadlock be loaded every time it calls class.forName ?. Is this a performance hit ?


Packages as such aren't loaded. Individual classes are loaded (once) when a class is instantiated that uses them.

3) Also if the underlying classes in the org.buddy.deadlock package are dependent on third-party applications will they also be loaded with the call to class.forName ?.


They, too, would be loaded (once, not again for each call) during instantiation, not during the class.forName call.
reply
    Bookmark Topic Watch Topic
  • New Topic