Basically, if I have the code:
public class Outer {
public int counter = 0;
public void makeNewThread() {
Thread t1 = new Thread(new Inner());
t1.start();
}
private class Inner implements Runnable {
public void run() { //do stuff involving counter... }
}
}
Everytime makeNewThread() is called, will each thread have their own version of counter, or will they all share the same version of counter? I would assume they would all share the same version since it's an inner class, but each thread has their own stack so I'm not sure.