Questions of how to divide the query processing with Thread
posted 3 years ago
I have an application that need to see some information in the database. They are about 12 queries that will be fired.
But this bank is very slow and sometimes this process can take up to 1 minute to complete. The time required would be around 15 seconds.
To answer this question, I chose to create some threads so that queries were processed in parallel and at the end, the results would be assigned to an object.
Never had the need to implement something like that and I've been doing some studies to verify the best cool.
I created an example that someone could tell me if the path is correct or wrong.
Below is an example.
Class to process the Threads.
The returned values are calculated by generating a result.
Class that returns an integer.
Class that returns a double
To facilitate the analysis of the result, one thread to put her to sleep for 10 seconds. This made it much easier for me to have an idea of how fast it was.
I hope I've been clear in explaining and I'm very grateful if anyone can help me with this issue because my primary need right now is to get the application to work as soon as possible.