This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Class.forName Thread Safe ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Class.forName Thread Safe ?" Watch "Class.forName Thread Safe ?" New topic
Author

Class.forName Thread Safe ?

Steven Rodeo
Ranch Hand

Joined: Mar 06, 2008
Posts: 72
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 ?.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35440
    
    9
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.


Android appsImageJ pluginsJava web charts
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Class.forName Thread Safe ?
 
Similar Threads
How to open File on server Using JCIFS or any other method
My very own MVC framework...
How to instanciate a class by name?
missing return statement {
Is the following program thread safe ?. Please help...