Is it possible to implement a multi-threaded class loader in Java? In a meta-driven framework I need to load several hundreds of classes in advance, ie, not as lazily as the system classloader. In order to accelerate this, I would like to better utilize current multi-core CPUs. Before I dive into that, I would be interested if somebody already has some experience on this issue or if it is possibly totally clear that perhaps defineClass()
is the bottleneck in this case.
Thanks Andre
I believe currently you will hit an exclusive lock. In JDK7, class loaders will be able to mark themselves as being parallel-capable.
As ever, I suggest possibly doing some back-of-envelope calculations and then suck-it-and-see.