aspose file tools*
The moose likes Servlets and the fly likes probelms in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "probelms in thread" Watch "probelms in thread" New topic
Author

probelms in thread

Karthikeyan Mogan
Greenhorn

Joined: Mar 05, 2012
Posts: 4
i have to contact a class which uses thread to process . The java class mainly contacts the database and gets me the result set. Say i will be contacting the java class which uses a thread for twice and the main thread needs to print the result returned by the java class. The main thread is the servlet . How to do this ? If i try to make the servlet to wait Exception occurs and if i try to retrive the result set in the servlet i am can get only the empty result set.

I am using a array of resultset in the java class. Suggest me a way how to process this. I need to obtain the result set from the java class in the main Thread that is in the servlet once the 2 threads have completed its execution .
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

Put the code into an ordinary Java application and get it working first. (My guess: Right now it doesn't work there either.) Then once it is working, put the code into your servlet.
Karthikeyan Mogan
Greenhorn

Joined: Mar 05, 2012
Posts: 4
If it doesnt work what needs to be done ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

Um, if it doesn't work then you need to act like a programmer and find out what the problem is.
Karthikeyan Mogan
Greenhorn

Joined: Mar 05, 2012
Posts: 4
Atlast foound the solution. Use join method in thread to make the child threads execute one after the another and store the result in a vector. Once the child threads complete the execution retrive the resultset from the vector.
but i was able to find this one out as i first tried with a seperate app and then included in my project . Thanks Paul for your advice.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

If you're executing the child threads one after another, what's the point of creating multiple threads?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Karthikeyan Mogan
Greenhorn

Joined: Mar 05, 2012
Posts: 4
No ! What i did is that make the parent thread wait until the child threads have completed the execution. Say you have some 100 child thread and the main thread need to wait until the child thread completes the execution . The child thread executes concurrently boss so there by efficiency will be improved.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: probelms in thread