首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Thread种为什么有contextClassLoader

2012-10-29 
Thread类为什么有contextClassLoaderJava的类委派加载机制是一个漂亮的方案,但是并不完美。如果单纯利用这

Thread类为什么有contextClassLoader

Java的类委派加载机制是一个漂亮的方案,但是并不完美。如果单纯利用这种机制,那么web应用就无法满足。

?

?

jetty的ContextHandler.hadle方法设置当前线程的contextClassLoader

?

?

?

// Set the classloader                if (_classLoader!=null)                {                    current_thread=Thread.currentThread();                    old_classloader=current_thread.getContextClassLoader();                    current_thread.setContextClassLoader(_classLoader);                }

?

?

我觉得这样做能让容器支持多个webapp。

?

我认为这是一种比较hack的做法,这样就在一定程度上打破了必须按照委派加载。

热点排行