• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class.forName Thread Safe ?  RSS feed

 
Steven Rodeo
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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 ?.

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!