请问HN:使用起来最简单和最难的并发模型是什么?

3作者: pkkm13 天前原帖
并发选项有很多。在Python中,你可以使用共享内存的线程、带队列的线程、带队列的进程、concurrent.futures、asyncio、trio或AnyIO。Java现在除了常规线程外,还提供了结构化并发和虚拟线程的预览。Go语言有CSP模型,而Erlang/OTP则有演员模型和监督树。在纯函数编程领域,软件事务内存似乎很受欢迎,但在其他领域则比较少见。 我对你们在这些并发模型方面的经验很感兴趣——哪些模型容易实现,哪些则是无尽的bug来源?我特别关注那些有大量长连接且正确性比性能更重要的用例,例如聊天服务器、MMORPG服务器、物联网中央系统等。
查看原文
There&#x27;s a lot of options for concurrency. In Python alone, you can use threads with shared memory, threads with queues, processes with queues, concurrent.futures, asyncio, trio, or AnyIO. Java now has a preview of structured concurrency and virtual threads in addition to regular threads. There&#x27;s also the CSP model of Go, as well as the actor model and supervision trees of Erlang&#x2F;OTP. Software transactional memory seems to be popular in the purely functional world but rare outside of it.<p>I&#x27;m curious about your experiences with these concurrency models - which are easy to get right, and which are endless sources of bugs? I&#x27;m particularly interested in use cases where there are lots of long-running connections and correctness matters more than performance: chat servers, MMORPG servers, IoT central systems, etc.