[ Sync- Async- Multithreading on server application ]
I'm actually making a server application, which should recover a lot of data from the DB. As it's a performance question to the main thread of the application, and the main thread needs to continue working while recovering data from DB, I need to know what are the best practices for such task. On one side I could use Threads, and as I understand, the main Thread assigns execution time to each sub-thread, is it possible to change/know the execution time assigned to each sub-thread? On the other side I have the posibility to use asynchronous Threads to do heavy work. So should I use sync or async Threads to do heavy work, and why?
Answer 1
An asynchronous operation should be executed in another thread. That is, you're implementing multi-threaded code too.
There's no other way to parallelize work than threading, either using multi-tasking or actual parallelism using CPU cores.
This is why there's no why as you expect. Why? Because you need to execute tasks while main thread continues processing.