I define a global static object as a synchronization lock.
public static Object ConfirmationSynObj = new Object();
The following function i
@Kayaman speaks correctly, as far as I can tell, however if I may humbly suggest: java.util.concurrent can save you lots of time!
What I'd use there is a semaphore.
From the docs: "Each acquire() blocks if necessary until a permit is available, and then takes it.".
But there are other choices too- I strongly recommend using this where possible, as you should avoid lots of pit falls as in your case.
Semaphore semaphore = new Semaphore(0);
new Thread(new Runnable() {
@Override
public void run() {
//this is a http request
appSignInfo = getAPKSignature(context, pkinfo.packageName);
semaphore.release();
}
}).start();
try {
semaphore.acquire();
} catch (InterruptedException e) {
e.printStackTrace();
}