Delay in thread startup?

T

Tim Ward

[I've tried searching for any previous discussion of this problem but none
of the keywords I can think of are specific enough to turn up anything
useful.]

I'm starting up up 30 threads at once.

Each is started by a Runnable-derived class doing this:

thread = new Thread(this, addr);
thread.start();

I log the time at which control returns from thread.start(); all 30 of them
return very close together.

Next, I'm logging the time at which each thread's run() starts running, the
logger call being the first line in the run().

The run methods are called at intervals of around two seconds, so something
somewhere seems to be serialising thread creation and putting a two second
delay (approx) between each, and I'm pretty sure it isn't any of the Java
code I'm running (some of which is mine and some of which is inherited).

Whilst this is happening CPU loading is quite low, so it's not caused by a
lack of CPU cycles. It's not the logger calls that are doing it either, as
overall behaviour of the application was the same before I added the logger
calls, all the logger calls are doing is telling me where the delay is.

(Of course the application doesn't work, as it's got timeouts way shorter
than the 50 seconds or so it takes for the last thread to start running and
it has long since given up and marked everything as failed.)

Questions:

(1) Am I imagining this delay, or is it really happening?
(2) What and where and why is it?
(3) How do I stop it?
 
T

Tim Ward

Tim Ward said:
The run methods are called at intervals of around two seconds, so something
somewhere seems to be serialising thread creation and putting a two second
delay (approx) between each, and I'm pretty sure it isn't any of the Java
code I'm running (some of which is mine and some of which is inherited).

Turns out to be the Netbeans debugger that's doing this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top