[HN Gopher] Multithreading for Dummies
       ___________________________________________________________________
        
       Multithreading for Dummies
        
       Author : ingve
       Score  : 5 points
       Date   : 2023-08-16 21:23 UTC (1 hours ago)
        
 (HTM) web link (www.science20.com)
 (TXT) w3m dump (www.science20.com)
        
       | sublinear wrote:
       | > I looked at the screen in disbelief. Could it really be that
       | easy? The whole thing would boil down to adding an #include
       | command at the beginning of my source code, and then embed into
       | functions the two parts that could be parallelized; a
       | synchronization command would suffice to restore single-threading
       | at the end of each fan-out.
       | 
       | Parallelization is good, but it still sounds like it runs
       | synchronously, so all the rest of the threads are stuck waiting
       | for the slowest one to join.
       | 
       | If you really want foolproof multithreading for dummies, write
       | all your code around an event loop that sends your tasks to a
       | thread pool backed by a message queue.
       | 
       | You can have your parent threads that glue everythhing together
       | still be synchronous, but the critical sections of code should be
       | executed asynchronously so the only threads being blocked are the
       | parents waiting for the completion event containing the results.
        
       ___________________________________________________________________
       (page generated 2023-08-16 23:02 UTC)