views:

51

answers:

2

Hi guys,

I am writing a J2EE application using Struts and Spring. In one of the operations there is heavy database processing, and hence performance issues. What I want to know is can I use multithreading here? I think the J2EE specification does not allow custom threads to be created apart from those created by Server(I use Weblogic). Please guide me through this.

+1  A: 

This question pops up once in a while.

As per the spec it's not authorized. The best page to look at is this one: Q/A: J2EE Restrictions

That said, there are ways to spawn threads, especiall in Weblogic with the WorkManager.

See these questions:

The fact that the first one targets EJB shouldn't matter that much, and the last one about access to file system is about general restrictions.

Hope it helps.

ewernli
+1  A: 

These restrictions are in place mostly because jee and ejb want to support transparent clustering. For example one server of a cluster should not modify files because these changes can not be easily mirrored to other servers. For threads there is the question if there should be one thread per cluster or per server. These threads also can not be easily monitored by the application server.

That said, it should be possible to create threads, socket connections or access the filesystem in a jee server just like in a normal application.

Jörn Horstmann