Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

create detached threads in a loop

33 views
Skip to first unread message

kushal bhattacharya

unread,
Mar 22, 2017, 2:45:50 AM3/22/17
to
Hi,
Could anyone please guide me how to make detached thread in a loop.I am getting some errors making it.

Alf P. Steinbach

unread,
Mar 22, 2017, 3:29:11 AM3/22/17
to
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

kushal bhattacharya

unread,
Mar 22, 2017, 3:33:37 AM3/22/17
to
hi,
Actually i want all those preswaned threads to run all the time for infinite amount of time until the program is ended

kushal bhattacharya

unread,
Mar 22, 2017, 3:37:23 AM3/22/17
to
Those threads should run in background
and should not block execution context

kushal bhattacharya

unread,
Mar 22, 2017, 3:46:56 AM3/22/17
to
Actually to be clear these thread are used for transmitting packets so these are run in background so that they can fetch message and deliver packets to client
Message has been deleted
Message has been deleted
Message has been deleted

kus

unread,
Mar 22, 2017, 5:01:46 AM3/22/17
to
Am i clear about my scenario now?

Alf P. Steinbach

unread,
Mar 22, 2017, 5:43:13 AM3/22/17
to
On 22-Mar-17 9:47 AM, kus wrote:
> test message from thunderbird

Yes, that works.

You're posting with


User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.7.0


Cheers!,

- Alf

kus

unread,
Mar 22, 2017, 5:49:34 AM3/22/17
to
On Wednesday 22 March 2017 12:59 PM, Alf P. Steinbach wrote:
hiii,
I came up with an idea about fetching threads from a configuration file.
Is it feasible?I mean about background threads here

Chris M. Thomasson

unread,
Mar 22, 2017, 7:32:32 PM3/22/17
to
On 3/21/2017 11:45 PM, kushal bhattacharya wrote:
> Hi,
> Could anyone please guide me how to make detached thread in a loop.I am getting some errors making it.
>

What errors? Any why do you need them?

kushal bhattacharya

unread,
Mar 23, 2017, 6:15:44 AM3/23/17
to
Actually i want to run those in background so that it doesnt inteferrs or disturb other operations
0 new messages