what can threads be used for??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what can threads be used for???

5th Oct 2016, 11:07 PM
Uwem Neku
Uwem Neku - avatar
3 Answers
+ 4
You can use them to increase performance as more work can be done concurrently. However the workload must be parallelizable. This can be useful in server and OS operations. You must be careful tho to synchronize so that race conditions do not occur. I would suggest researching more
7th Oct 2016, 1:48 AM
Michael McGaha
Michael McGaha - avatar
+ 4
Some actions like loops sometimes cause the app to hang. The reason is:when you create an app , it always has a MAIN THREAD which handles UI operations. When a long action like a long loop runs on MAIN THREAD , the thread stops handling UI actions and process the loop , which cause the UI of the app to get LOCKED until the loop isn't finished . So if you excute the loop on another thread it won cause the app UI to get locked.
7th Oct 2016, 1:03 PM
AmirHosein Mansoori
AmirHosein Mansoori - avatar
0
for background processing
26th Dec 2016, 5:46 AM
Ravi Kumar
Ravi Kumar - avatar