On 22-Mar-17 7:45 AM, kushal bhattacharya wrote:
> Could anyone please guide me how to make detached thread in a
> loop.I am getting some errors making it.
Technically,
for( int i = 1; i <= 3; ++i ) { thread{ &my_func }.detach(); }
Add any thread function arguments as additional arguments after the
function address.
But I strongly suspect that creating detached threads is not a solution
to your problem, that instead it will turn out to be a problem itself.
What are you trying to solve by doing this? Why do you want to detach
the threads?
Cheers & hth.,
- Alf