Re: Delay time to spawn new threads?



Hi Andrew,

Yes, I've tried the printf thing. It takes about 1.5 sec. Very strange. 

Dave




________________________________
 From: Andrew Potter <agpotter gmail com>
To: David Buchan <pdbuchan yahoo com> 
Cc: gtk-app-devel-list list <gtk-app-devel-list gnome org> 
Sent: Wednesday, November 27, 2013 1:24 PM
Subject: Re: Delay time to spawn new threads?
 

On Wed, Nov 27, 2013 at 7:29 AM, David Buchan <pdbuchan yahoo com> wrote:

I have written a program which spawns a new thread when the user clicks a button. The new thread does 
something noticeable immediately after starting, so I know when the thread has begun. What I mean is, if I 
run that piece of code that is executed as a new thread, but as a stand-alone program, it does it's thing 
immediately.

However, when I have it run as a new thread when the user clicks a button, it takes about 1.5 seconds 
before it does its thing.


I've done this with g_thread_create() and g_thread_new() with identical results. Is it normal for there to 
be a 1.5 sec delay, or have I bumbled something?

While there is some cost to spinning up a new thread, it should be a
much much less than 1.5 seconds. I suspect the problem may be
elsewhere; what precisely is "something noticeable"? Are you creating
or modifying GTK elements in your new thread? All GUI operations have
to be done on the main thread (e.g. thread with the GMainLoop).

Try putting a printf() at the start of your new thread; does that take
1.5 seconds to show up on stdout?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]