I'm looking for a safe way to pass an object from a background thread to the UI thread. Does the code below do it safely?
// on background thread
final HugeObject object = constructHugeObjectFromDatabaseAndNetwork();
uiThreadHandler.post(new Runnable() {
public void run() { doSomethingWithObject(object); }
});
I.e., do JMM rules allow the object to be in fact partially constructed during the doSomethingWithObject call? Also, how relevant JMM is for Android and its virtual machine?