Hacker News new | past | comments | ask | show | jobs | submit login

Or just create a Queue(), give it as a parameter to the long calculation so it can store the result in it, and in the main thread just do q.get(). There are probably a dozen other synchronization primitives you can use, but this one is very versatile and you only need to keep one API in your head. Also, this approach somewhat mimics the concept of channels in Go.



This is among the best concurrent programming advices I've ever been given and have given out. Use a queue and a pool of workers. It makes your synchronization so much easier and simpler.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: