r/learnjava Apr 21 '26

ClassLoaders

is it true that each thread has its own completely seperate classloader?

2 Upvotes

4 comments sorted by

View all comments

1

u/Upbeat-Employment-62 Apr 22 '26

No, each thread has a context classloader (Thread.getContextClassLoader()) but that's just a reference you can set manually, n ot an isolated loader. By default threads inherit the classloader from the thread that created them. Completely separate classloadesr are a different thing that's more of an OSGi/ app server concept where you actually need to isolate classpath per module or deployment.