I'm kind of confused about what you are saying. In java, in a single threaded application the code will always follow a deterministic, in-order execution path.
It sounds like you have a multi-threaded application, in which case things can happen out of order.
E.g if SpwanThread starts some thread to compute someFunction(...) in th background then result wont be initiilized by the time the if statement is processed.
Code:
int result = SpawnThread(someFunction(someInputValue) );
if (result == 0)
{
doSomething...
}
You need to look into mutexes, locks, detached and joined threads.