Should the ClassLoader to be thread-safe? Does it make sense to cache the loaded classes?

In Java there is such a thing as a's Classloader, but the method defineClass() it is not synchronized, as well as methods findClass() and loadClass(), which is strange, because different threads can access these methods at the same time, resulting in re-downloading for example.

Is it worth doing a custom loader is thread-safe?

And, I think this should be closely linked: whether to create a custom loader nesiruosiu if the download class — long process?
October 10th 19 at 14:18
1 answer
October 10th 19 at 14:20
No, everything is already done for you.
The method loadClass(String name, boolean resolve) synchronized.
The second time the same class will not be loaded, so manual caching makes no sense.
Thanks, as it passed by. Everything goes OK if I extend it through findClass inheritance. But the answer to the question turns out Yes, need :) - Trudie.Kuphal commented on October 10th 19 at 14:23
On the question "Should the ClassLoader to be thread-safe" the answer is Yes, and the question "is it Worth doing a custom loader thread-safe" — no, it will work itself out.
I guess on the second answer :-) - Noemy.Macejkovic94 commented on October 10th 19 at 14:26

Find more questions by tags OraclemultithreadingJava