Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #27942

java thread question

Newsgroups comp.lang.java.programmer
Date 2014-04-03 07:51 -0700
Message-ID <ffb65076-f551-432b-b548-303a884abd44@googlegroups.com> (permalink)
Subject java thread question
From mcheung63@gmail.com

Show all headers | View raw


Hi All
    I have write a little program to keep running some threads, i got questions:
1) All threads are running within one process (ps command show me this), but it will eat up all cpu cores, how to explain this?
2) If thread will eat multiple cpu core, why wee need fork/join in java?

public class TestThread implements Runnable {
	public static void main(String args[]) {
		for (int x = 0; x < 10; x++) {
			new Thread(new TestThread()).start();
		}
	}

	@Override
	public void run() {
		double r = 1.2323;
		while (true) {
			r = r * r + Math.pow(r, r);
		}
	}
}



thanks
from Peter (cmk128@hotmail.com)

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

java thread question mcheung63@gmail.com - 2014-04-03 07:51 -0700
  Re: java thread question Nigel Wade <nmw@ion.le.ac.uk> - 2014-04-03 16:17 +0100
  Re: java thread question Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-04-03 11:43 -0400
    Re: java thread question mcheung63@gmail.com - 2014-04-03 15:10 -0700
      Re: java thread question Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-04-03 19:00 -0400
        Re: java thread question mcheung63@gmail.com - 2014-04-04 09:29 -0700
  Re: java thread question Roedy Green <see_website@mindprod.com.invalid> - 2014-04-03 17:52 -0700
    Re: java thread question mcheung63@gmail.com - 2014-04-04 09:31 -0700
    Re: java thread question Roedy Green <see_website@mindprod.com.invalid> - 2014-04-04 09:49 -0700
      Re: java thread question mcheung63@gmail.com - 2014-04-05 09:41 -0700

csiph-web