Andrey
Andrey

Reputation: 98

What will happen if i run a 2 threaded application on a vps server with 1 thread?

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!

Upvotes: 1

Views: 350

Answers (1)

Ali Sajjad Rizavi
Ali Sajjad Rizavi

Reputation: 4520

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.

Upvotes: 6

Related Questions