News for hackers. Stuff that matters.
Re:Ask HN : Have you ever programmed with threads? by jbooth on Friday March 05, 2010 @01:23PM (#1170031)
Try to make the handoffs between threads as coarse-grained as possible. Passing data between threads means your thread acquires some lock, leaves the data there, then the other thread has to acquire the lock before getting the data -- both situations could involve a thread blocking and going to "blocked", then "runnable", then finally at some point in the future actually being executed and doing their work. If the tasks you're parcelling out are too fine grained and require too much communication, the scheduling overhead will outweigh the parallelism -- and you could be getting effectively singlethreaded performance plus overhead.

There are no comments on this comment yet.