digitalmars.D.learn - Close Threads
- candle (12/12) May 28 2018 Hey Folks.
- candle (6/6) May 28 2018 sorry about my double post, but:
- =?UTF-8?Q?Ali_=c3=87ehreli?= (12/30) May 28 2018 The problem is, the threads are all in their while loops, never checking...
Hey Folks. I have a question about threading and how to close threads i don't need anymore. In the following code, i build 3 threads with spawn from the concurrency module. if one thread found the number, all others thread must stop search. but i have a big logical problem in my mind. i hope someone can help me to find a solution. Happy Greetings and here is the code: https://pastebin.com/vQRediG6
May 28 2018
sorry about my double post, but: the receive in the search function, was first under (in) the (guess =! searchFor) block, but it was the same effect. for testing i have these writeln("test1 and 2"). writeln(guess) i have never seen. is receive a loop itself ?
May 28 2018
On 05/28/2018 11:47 AM, candle wrote:Hey Folks. I have a question about threading and how to close threads i don't need anymore. In the following code, i build 3 threads with spawn from the concurrency module. if one thread found the number, all others thread must stop search. but i have a big logical problem in my mind. i hope someone can help me to find a solution. Happy Greetings and here is the code: https://pastebin.com/vQRediG6The problem is, the threads are all in their while loops, never checking 'finish' message. You need to move the 'receive(bool finish)' checking inside the while loop but you must replace it with receiveTimeout with 0 duration, otherwise your receive call will block until a message arrives: receiveTimeout(0.msecs, (bool finish) { if(finish == true){ return; } }); Ali
May 28 2018