Are Generators Threadsafe?

后端 未结 6 865
闹比i
闹比i 2020-12-02 09:29

I have a multithreaded program where I create a generator function and then pass it to new threads. I want it to be shared/global in nature so each thread can get the next

6条回答
  •  难免孤独
    2020-12-02 09:58

    No, they are not thread-safe. You can find interesting info about generators and multi-threading in:

    http://www.dabeaz.com/generators/Generators.pdf

提交回复
热议问题