• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

probelms in thread

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it doesnt work what needs to be done ?
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Um, if it doesn't work then you need to act like a programmer and find out what the problem is.
 
Karthikeyan Mogan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're executing the child threads one after another, what's the point of creating multiple threads?
 
Karthikeyan Mogan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic