Since you dint want to do async task,making the thread sleep may freeze the UI. Even if it didn't, it is still insanely bad practice.
so first thing - you have to do it on a separate thread. and Asynctask is best for it.
some_function() would be executed before //Some code 2 if it is not running on a separate thread(As you said its not Asynctask).But in case it is running on a separate thread(which it should be)-.
you can just simply call "//Some code 2" inside some_function() at the end.
OR
if you do not want to do that,try it like this-
First make an interface -
public static interface On_some_function_complete{
void onComplete(what ever parameters you want);
}
put an instance of this interface in your some_function()
as parameter where ever you define it and call the onComplete method in the end of the function ,like-
void some_function(On_some_function_complete arg_on_complere){
//what ever stuff your code dose
arg_on_complere.onComplete(/*with required arguments*/);
}
now make call like -
void A()
{
//Some Code 1
some_function(new On_some_function_complete{
@Override
public void onComplete(Bitmap result) {
//Some code 2
}
});
}
OR
you must have some function that you can override to handle on-Compete action