M
mcheung63
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 ([email protected])
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 ([email protected])