Here is my code :
final int g = 0;
ExecutorService threadPool = Executors.newFixedThreadPool(10);
for (int i = 0; i < 10; i++) {
threadPool.submit(new Runnable() {
public void run() {
g++;
myFunc(g);
}
});
}
Obviously this doesn't work because of concurrent access on the variable g.
I've tried a lot of things, but didn't manage to find a nice and easy way to fix it. Any solutions ?
Thanks.