I have a quad processor. I coded something like that in java;
Some.java;
public class Some extends Thread { private SharedData sharedVal; private String name; public Some(SharedData val, String threadName) { sharedVal = val; name = threadName; } public void run() { int temp; while(true) { temp = sharedVal.GetValue() + 1; sharedVal.SetValue(temp); } } } SharedData.java;
public class SharedData { private int value; SharedData() { value = 0; } public void SetValue(int d) { value = d; } public int GetValue() { return value; } } Program.java;
public class Program { public static void main(String[] args) { SharedData test = new SharedData(); Some t1 = new Some(test, "thread1"); Some t2 = new Some(test, "thread2"); Some t3 = new Some(test, "thread3"); Some t4 = new Some(test, "thread4"); t1.start(); t2.start(); t3.start(); t4.start(); } } I run program and check processor graphics, each processor part looks working around %90.
My question is; if i can use system resources like this, what is the parallel programming? Am i getting it wrong? I saw an example on c# using processor count, what is the deal with that?