When should be program block dynamic or static ? members of static program block , members of automatic program blocks?

In reply to sriram.seshagiri:

Like I said earlier, just declaring a variable automatic is not enough to fix the problem. You need to make sure there is a separate instance for each invocation of the thread. There is only one instance of the automatic variable i shared amongst all the threats. But there is a new instance of the variable j for every loop iteration/thread.