• Post Reply Bookmark Topic Watch Topic
  • New Topic

Threads for calling procedures

 
Radhakrishnan Ranjit
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 procedures to be called to build my view layer. Each one of my procedure is taking around 10 seconds execution time. If I go in a sequential way then my wait time will be 20 seconds (after completion on both the calls) and then I will have to take it to the view layer.
Can I use thread implementation in this scenario? Have a Thread A to fetch Procedure 1 and have Thread B to fetch Procedure 2.

Thanks
Ranjit Radhakrishnan
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Possibly. Threads would allow both procedures to execute at the same time, cutting that 20 second wait back down to 10 seconds (or less depending on how those procedures work). But the ability to run code in parallel efficiently has a lot to do with the procedure to be run. So, generally yes, Threads will make multiple tasks complete faster, but your specific tasks may or may not be faster in parallel then in series.

As a matter of standard operation, though, those procedures should be done in a different thread then the one rendering your GUI (the event dispatch thread), regardless of if you do them in one or multiple threads. This will allow your GUI to respond and repaint while the procedures execute. See this page.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!