Hi there
I´d like to know how to secure that a method is fully done before anything else happens that might
interfere with the methods tasks.
F.e. when I want to load a map from a file and secure that it´s fully loaded before the paint()-method draws the map.
I think sometimes java jumps to the next task before the last one is fully completed.
Let my method be loadMap(); and
the code be
public void doWhatever(){
loadMap();
saveMap();
}
I experienced java trying to start the saveMap() method before fully finishing the loadMap() method
which of course causes some serious problems.
I tried to solve the problem by doing the following:
public void doWhatever(){
if( loadMap() ) { }
saveMap();
}
public void loadMap(){
[…]
return true;
}
I guess with this the method calling loadMap() waits until it receives the return true and then continues its tasks.
I hope this is right, but is there a better way ?