have two questions. Please assume multiprocessor machines with each
thread running on separate cpu's. Also, if you can point me to any
reference that backs your opinion/fact would be great. Am I safe on both
of the following?
1. Lets say I have the following
public class MyTest extends
static int i =
// Please not NO
let's say that I spawn 2 of these and they are on different cpu's and they
both execute i++ at the same time. Is there EVER a chance that the
result of i can EVER be 1 or will it always be 2.
2. Now here is another code
static ArrayList myStaticList =
public ArrayList getList(boolean
only sync on refreshing, not getting
ArrayList newList = new ArrayList();
// Code here to get new list from database and fill
myStaticList = newList;
question is that let's say that one thread (different cpu) is executing return
myStaticList at the same time as another thread is executing myStaticList =
newList. Is it possible that the return myStaticList will EVER return a
half/limbo state object or worse yet a Dr. Watson or
is wanted and appreciated.