Is possible to have 2 child threads with different classpath in each one?

a 夏天 提交于 2019-12-03 09:02:24

Indeed:

URLClassLoader cl = new URLClassLoader(urls);
Thread thread = new MyThread();
thread.setContextClassLoader(cl);
thread.start();

Use Thread.currentThread().setContextClassloader() and make a new URLClassLoader with the desired classpath.

Yes you can. using Thread's setContextClassLoader method.

check following link(little old but useful) for understanding it better:

http://www.javaworld.com/javaworld/javaqa/2003-06/01-qa-0606-load.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!