We have a legacy validation framework that is singleton only and can not be used in a multi threaded way. We would like to instantiate multiple instances of singletons in stateless EJB's to speed up batch processing of files, however we are legally not allowed to change the source code of said framework.
Is there any workaround here to solve this problem? Thanks!
EDIT: Lots of subclasses in this framework are using singletons as well as static attributes, so no multi threading possible :-/
答案 0 :(得分:0)
需要有关此遗留框架的更多详细信息,但单例对象与多线程性能之间没有任何关系。如果此对象是无状态的,则可以在没有性能问题的情况下以并行方式处理文件。
因此,例如,如果您实现Message Queue和Message Driven Beans,则每个进程都将是一个可以同时工作的MDB实例。直接在服务器上使用线程API并不好。