R
Roedy Green
I have difficulty seeing how you wouldn't be able
to figure out how many threads you propose to start.
I easily do it, it is just that in my case it takes an extra pass.
I have difficulty seeing how you wouldn't be able
to figure out how many threads you propose to start.
I use the -Xss on occasion for some apps, sometimes it's part of theirYes, no, it depends.
It is implementation dependent so it can and do differ between
different vendors and platforms.
Some may provide an option for changing the default.
I have once read that SUN/Oracle Java on Windows and Linux uses
320 KB and 1024KB as default on 32 and 64 bit respectively.
SUN/Oracle Java do provide the -Xss option to change the
default.
Arne
I am surprised that this got just one mention so far.
I am also interested. However, I will say that I would have used theCan you be more specific about when shutdown and await does
not work?
Arne
I use the -Xss on occasion for some apps, sometimes it's part of their
tuning docs. Usually I don't worry about thread stack size, not if I've
got a relatively small number (25 certainly being small) of threads.
Not when I need GB of memory for heap, and hundreds of megs for perm gen.
My approach here is my usual approach - go for a simple design, and if a
quick gut-check of performance implications raises no red flags then go
with that for implementation.
Arne Vajhøj said:Can you be more specific about when shutdown and await does
not work?
Arne
You can always join() them.
I am surprised that this got just one mention so far. In absence of
Executor (which has some issues, as has been mentioned) this is the most
straightforward way to do it.
// untested and from memory
final Thread[] threads = new Thread[15];
for ( int i = 0; i < threads.length; ++i ) {
final Thread th = new Thread(...);
th.start();
threads = th;
}
for ( final Thread th : threads ) {
th.join();
}
Kind regards
robert
variable sized thread pool is the worst (glitches maybe 10% of the
time!) but the others have rare glitches too. These glitches are fixed
when a new task is queued so a steady stream of tasks appears to work
correctly. What happened with the very last task is a gamble. That's
why you shouldn't use shutdown() to wait for completion.
I'm not going to walk through the code here. It's awful stuff that's
markspace said:Hmm, could you produce a code example that glitches 10% of the time?
Otherwise I'm afraid that I'll have to file your claims under "internet
b.s." There's no way I'm going to believe that Oracle's code is that
buggy just on hearsay.
markspace said:Hmm, could you produce a code example that glitches 10% of the time?
Otherwise I'm afraid that I'll have to file your claims under "internet
b.s." There's no way I'm going to believe that Oracle's code is that
buggy just on hearsay.
Fixed size pools have some problems too but they're less frequent and
unobtrusive. You'd probably never hit them unless you're using
shutdown() rather than Future.get() to wait for task completion.
Could be more specific?
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.