multithreading - When multi-threading is a bad idea? -


according way understand threads, programming multi-threaded program either can speed program or match execution time of single-threaded version of program.

so, 2 questions are:

1- said true or false ?

2- give example when multi-threading code produce negative results on performance ?

a multi-threaded program can behave worse single-threaded equivalent. due to:

  • the cost create additional threads
  • the cost of context switches
  • the potential false sharing.

creating many threads small amount of work alters adjacent regions of memory exhibit of issues.

multi-threaded programs in general introduce additional complexity , present numerous opportunities bugs. should taken account when deciding whether or not use multiple threads.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -