• Post Reply Bookmark Topic Watch Topic
  • New Topic

Ques about parallel thread  RSS feed

 
quitejack
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all
Could any one help me to run a group of thread in the same time ? I've tried to made 50 thread at the same time, use
"for (50 times){new threads}", but when I try to run them at the same with the runflag from false to true, it seems all the threads runs one by one.
Who could give me a solution or explanation ?

 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's get the formalities out of the way first. Can you please review our naming policy and reregister under a valid name? Thanks.
How do you know the threads run one by one, and what does your code look like? On a single-CPU machine, strictly speaking, you never run more than one thread at a time. Also, if you use a JVM with green, non pre-emptive threads, then such a thread may monopolise the CPU if it doesn't do any I/O, sleep(), wait() or yield(). Finally, synchronization may cause single-threading too.
- Peter
 
dan moore
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is this runflag of which you speak?
cheers, dan.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!