cancel
Showing results for 
Search instead for 
Did you mean: 

j2ee and threads

Ronib
Participant
0 Kudos

hi

i have a question : if i use threads in my application to call web services , does the j2ee engine will really open new threads and submit the requests simultaneously ?

i will appreciate any help

Roni.

Accepted Solutions (1)

Accepted Solutions (1)

Sigiswald
Contributor
0 Kudos

Hi Roni,

I suppose so. But I would be VERY cautious about starting your own threads.

Kind regards,

Sigiswald

Ronib
Participant
0 Kudos

can you point me to the official resources that say so?

Answers (1)

Answers (1)

Former Member
0 Kudos

Roni,

<i>if i use threads in my application to call web services , does the j2ee engine will really open new threads...</i>

If <b><i>you</i></b> use threads, then <b><i>you</i></b> start threads (I mean, your custom code starts them).

J2EE engine does not start new threads when you are executing WebService, all execution is done within current execution thread.

Sure, you may start your own thread and invoke WS from <i>run</i> method. This way your current execution thread and WS request will be processed in parallel. However, opening own threads (and explicit thread management in general) is highly not recommended in J2EE applications (specification is not clear about Web applications, but it states explicitly that this is forbidden for EJB code).

If you really want just to fire one-way WS call (there are no result or you are not interesting in result or result is not necessary for UI) then you may post a message to JMS topic/queue, then write MDB that processes this topic/queue and executes WS call.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Ronib
Participant
0 Kudos

Dear Valery,

the response from the web services should be display on screen.

i want to execute them in parallel. now, one web service wont start until the previous one end! and that is very bad for performance.

do you know a way to acheive such a scenario ?

your advice is highly appreciated!

Roni.