Issue
for my future project i would like my app to be live 24/7 on a Linode/UpCloud vps with 1 thread. My app uses threading python library for multiple tasks, what will happen if i run that app on 1 thread? Thanks!
Solution
Short Answer:
It will run fine. E.g.
- Thread 1 is given CPU
- Thread 2 is given CPU
- Thread 1 is given CPU
- Thread 1 is given CPU
- Thread 2 is given CPU
Explanation:
Multithreading does not necessarily mean that it is also multi-processing. If there is only one CPU with one thread, then the threads in your application will run turn by turn (almost). And this context switch will be so fast that you cannot even feel it.
EDIT (Thanks Barmar's comment):
It's called "timesharing", and it's how multiple processes work whenever the computer only has one CPU.
Answered By - Ali Sajjad Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.