jeudi 30 mars 2017

How does Class.forName(..) work, detailed?

First of all, I know that Class.forName() load a specific class to classloader and call it's static initializers. But, not long ago I found a problem in my company's application, we use some Http Client which call every http request Class.forName(...), that's cause problems during peaks of load. It locks hundreds of threads in monitor inside forName(...).

Here is the picture of my threads, they all waiting monitor!!!

enter image description here So, here is my questions:

  1. Is it scan classpath and all jars inside web application? (can it be a long operation?)
  2. Is it scan every call or if the class already loaded - it doesn't scan classpath?




Aucun commentaire:

Enregistrer un commentaire