Does JavaME and/or Proguard reorder assignments?
- by chrisdew
This is a simplified example - I have two threads:
Can JavaME and/Proguard ever reorder the obX = ... statements, such that thread_B will have a null pointer exception at ob2.someMethod?
thread_A:
Object ob1 = null;
Object ob2 = null;
...
ob1 = something1;
ob2 = something2;
thread_B:
if (ob2 != null) {
ob1.someMethod();
...
}
P.S. I do realise that synchronising these will avoid the issue. Synchronisation has both a performance overhead, and more importantly, a chance to introduce deadlock.