I am a beginner and do not natively speak English, so please bear with me and my English.
I am trying to understand for loops in threads. I am having a problem with threads here. These threads represent methods that take money from a account and the other thread adds money to that account.
You start off with a 1000 euro's on that account.
The problem is that i don't understand why there has to be a for loop with these numbers. I get the i = 0; and i ++, but why the i <1200000?
What am i achieving with this i < 1200000;?
Here are my threads:
The first one takes money from the account.
public class AfThread extends Thread {
private Rekening deRekening;
public AfThread(Rekening r) {
deRekening = r;
}
public void run() {
for (int i = 0 ;i < 1200000 ;i++ ) {
deRekening.neemOp(600.00);
if (deRekening.getSaldo() < 0)
System.out.print("rood "); // wordt met wait() nooit uitgevoerd
}
}
}
Adding thread:
public class BijThread extends Thread {
private Rekening deRekening;
public BijThread(Rekening r) {
deRekening = r;
}
public void run() {
for (int i = 0 ;i < 1200000 ;i++ ) {
deRekening.stort(600.00);
}
}
}