182
            
            votes
        
        
            
        Does it ever make sense to use more concurrent processes than processor cores?
                    The canonical time when you use far, far more processes than cores is when your processes aren't CPU bound. If your processes are I/O bound (either disk or more likely network), then you can ...
                
            
       
        
            
                59
            
            votes
        
        
            
        Does it ever make sense to use more concurrent processes than processor cores?
                    Short answer: Yes.
Longer answer:
Set your magic number stupid high, benchmark it, set it low, benchmark it again, and keep doing that until you have your answer.
The number of moving parts here is ...
                
            
       
        
            
                51
            
            votes
        
            
                
                Accepted
            
        
            
        What causes unpredictability when doing multi threading
                    Your understanding of computer hardware is flawed. Memory is not accessed by different cores in parallel, access is regulated like traffic at a road junction. Different threads can run simultaneously ...
                
            
       
        
            
                41
            
            votes
        
        
            
        Why is multithreading not used everywhere?
                    Why multithreading isn't everywhere?
Because …
I understand that multi-threading is hard to implement and has drawbacks if number of threads is less than expected.
                
            
       
        
            
                29
            
            votes
        
            
                
                Accepted
            
        
            
            
        Why is multithreading not used everywhere?
                    The proliferation of multi-core CPUs is predominantly driven by supply, not by demand.
You're right that many programmers don't bother decomposing their systems so that they can profit from multiple ...
                
            
       
        
            
                26
            
            votes
        
        
            
        Why do modern operating systems *ever* have perceptible input (keyboard/mouse) lag?
                    As you may have noticed, there's a category of application that tries really hard to avoid input lag and only occasionally fails at doing so: games. Even then it's not uncommon for players to notice ...
                
            
       
        
            
                25
            
            votes
        
        
            
        Why do modern operating systems *ever* have perceptible input (keyboard/mouse) lag?
                    I would like to answer this question from more of a high-level, marketing perspective than a more low-level, technical one.
All of the current mainstream Operating Systems are so-called general ...
                
            
       
        
            
                24
            
            votes
        
            
                
                Accepted
            
        
            
            
        Writing public libraries: Should I let the consumer of the library enforce thread safety?
                    You should make your library thread-safe, but that does not mean that you should be sprinkling synchronization primitives around your code base.
For the average library, which is not explicitly ...
                
            
       
        
            
                23
            
            votes
        
        
            
            
        Why is multithreading not used everywhere?
                    Why multithreading isn't everywhere?
Frame challenge: but it is everywhere.
Let's see, let's name some platforms:
Desktops/laptops: one of the most common applications today is the browser. And to ...
                
            
       
        
            
                20
            
            votes
        
        
            
        Why do modern operating systems *ever* have perceptible input (keyboard/mouse) lag?
                    Why can't (or why don't) operating systems absolutely prioritise user input (and repainting thereof) in threading and process scheduling?
Even if the operating system tells the application about the ...
                
            
       
        
            
                18
            
            votes
        
        
            
            
        Why is there a shift towards asynchronous and event driven programming?
                    The "async" approach better facilitates human reasoning.
When most people drive, they don't need to concern themselves with how every element of the car is interacting. Forget the tires - ...
                
            
       
        
            
                16
            
            votes
        
            
                
                Accepted
            
        
            
        Alternative to Actor model
                    Three paradigms in common use are actors (e.g. Akka), Software Transactional Memory (e.g. Clojure) or traditional manual lock-wrangling. They all have their own challenges.
Traditional lock-based ...
                
            
       
        
            
                16
            
            votes
        
            
                
                Accepted
            
        
        How could thread safety be provided by a programming language similar to the way memory safety is provided by Java and C#?
                    Races occur when you have simultaneous aliasing of an object and, at least, one of the aliases is mutating.
So, to prevent races, you need to make one or more of these conditions untrue.
Various ...
                
            
       
        
            
                16
            
            votes
        
        
            
            
        Can multi-threading improve performance of an IO-bound process?
                    I/O performance has two aspects that you must distinguish: latency and throughput. One measures how long you have to wait for the first byte of a response, the other how long you have to wait ...
                
            
       
        
            
                15
            
            votes
        
            
                
                Accepted
            
        
            
            
        Unit test which asserts that current thread is the main thread
                    Let me show you my favorite unit test principles:
  A test is not a unit test if:
  
  
  It talks to the database
  It communicates across the network
  It touches the file system
  It can't run at ...
                
            
       
        
            
                14
            
            votes
        
            
                
                Accepted
            
        
            
        How do you test and demonstrate that you have properly prevented a race condition?
                    Sometimes you have some control over the timing, and you can intentionally force a race in a test. When you are using a guarantee of an external system like a database, you usually can't control the ...
                
            
       
        
            
                14
            
            votes
        
            
                
                Accepted
            
        
        Can functional programming languages have deadlock conditions?
                    The quote is correct in principle. If you don't have any mutable state or side effects then you don't need to lock anything and without locks you don't get deadlocks.
But in reality, most programs, ...
                
            
       
        
            
                13
            
            votes
        
            
                
                Accepted
            
        
            
        Is it okay to start a thread from within a constructor of a class
                    Initializing the object completely in the constructor is usually preferable because it reduces the number of states, and thus making your object easier to reason about. No start and stop methods ...
                
            
       
        
            
                13
            
            votes
        
        
            
            
        How could thread safety be provided by a programming language similar to the way memory safety is provided by Java and C#?
                    Java and C# provide memory safety by checking array bounds and pointer dereferences.
It's important to first think about how C# and Java do this. They do so by converting what is undefined behaviour ...
                
            
       
        
            
                13
            
            votes
        
            
                
                Accepted
            
        
            
            
        If the whole point of recursion is to break the problem into multiple smaller problems, what if those problems were solved in parallel?
                    Recursion isn't really about breaking problems into smaller ones or enabling concurrency; it's about solving self-similar problems.
Consider this representation of a Binary Search Tree:
public class ...
                
            
       
        
            
                13
            
            votes
        
            
                
                Accepted
            
        
            
            
        Implementing a hash table with true concurrency
                    I have wrestled with this. I did a few iterations on my design...
First solution: Just have a hash table with a global lock.
Second solution: Wait free fixed size hash table. We need to figure out ...
                
            
       
        
            
                12
            
            votes
        
            
                
                Accepted
            
        
        Immediately awaiting an asynchronous call
                    I think you misunderstand the await call.  What async and await do is allow the thread you are executing on (not just the main thread) to continue working.  The mechanism that supports this is called ...
                
            
       
        
            
                12
            
            votes
        
        
            
            
        Is the meaning of `const` still thread-safe in C++11?
                    The video you cited is for an advanced and expert audience. Herb Sutter tries to bring this audience to a consensus on how to best communicate the intent of these keywords to other people, in this age ...
                
            
       
        
            
                12
            
            votes
        
        
            
        Does it ever make sense to use more concurrent processes than processor cores?
                    In A.I. it is common for people to observe super-linear speedups when they write parallel algorithms (that is, > K times speedup with K processes running on K cores). This is because you are often ...
                
            
       
        
            
                11
            
            votes
        
        
            
        Why is multithreading not used everywhere?
                    I want to emphasize a point you made that multithreading is hard to implement. Some problems are naturally broken into independent parts that are easily parallelizable ("embarrassingly parallel&...
                
            
       
        
            
                11
            
            votes
        
        
            
            
        Does it ever make sense to use more concurrent processes than processor cores?
                    You can take the example of compiled Linux distributions (like Gentoo): to optimize the compilation time, it is obviously using parallel compilation using more processes than the number of available &...
                
            
       
        
            
                11
            
            votes
        
        
            
        Why do modern operating systems *ever* have perceptible input (keyboard/mouse) lag?
                    In my experience, on most computers I have ever used, this is usually caused by inappropriate swapping to disk. Every other cause (such as operating system locks) is significantly less common.
When ...
                
            
       
        
            
                11
            
            votes
        
            
                
                Accepted
            
        
            
        How can a web browser simultaneously run more videos than the number of CPU cores?
                    is each window running a separate thread, where the threads are switching quicker than I can differentiate them?
Yep, pretty much this.  If you look at task manager or other tool you will see ...
                
            
       
        
            
                11
            
            votes
        
            
                
                Accepted
            
        
            
            
        What problem does Rust's "atomic reference count" actually solve?
                    The problem is there is an assumption violation in the sequence of events:
object has ref-cnt 1
This implies that object is only visible from 1 Arc reference. In rust this also implies that there are ...
                
            
       
        Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
multithreading × 684java × 122
concurrency × 101
c# × 87
c++ × 76
design × 52
c × 40
design-patterns × 30
architecture × 29
.net × 29
performance × 25
python × 24
asynchronous-programming × 22
locks × 22
synchronization × 20
parallelism × 20
operating-systems × 19
cpu × 19
multiprocessing × 16
c++11 × 15
async × 15
parallel-programming × 14
multi-core × 14
linux × 13
io × 13
 
         
         
         
         
         
         
        