Reputation: 37
I have a simple loop in a thread, and I'd like to stop the loop. Normally with Python, I would use a global variable to stop the loop, but I don't know for Rust.
I heard about channels, but I don't know how to pass a channel Receiver
into my function which starts a new thread.
Upvotes: 2
Views: 2084
Reputation: 43042
Channels seem like overkill for a simple loop condition. You can use an atomic variable instead which can be shared across threads.
Upvotes: 3