Thread in Jar verify it in Unity

I am writing my first plugin in Unity. As part of the plugin(i.e in Android studio) i am supposed to connect to database using a Async thread class. Exported it as Jar and imported in Unity . back in unity i need to hold my function calls until connected with Database. So how can i perform that.

Code in Android Studio

public class AndroidToDatabase extends
AsyncTask{
private String URLresponse;
@Override
protected String doInBackground(String… uri)
{
return URLResponse
}

I tried using a check with URLresponse at Unity Side

Unity Code :

IEnumerator Initilize() {
yield return StartCoroutine(getURLResponse()); }

IEnumerator getURLResponse() {
pluginClass.Call (“Init”);

//Android Studio Function Which executes my Async thread i.e AndroidToDatabase class

string response= pluginClass.Callstring;

// Returns the URL response from Android Studio

}

always returns Null. please help me get through this.

Ok I see, I think I misunderstood your question.

Its coming back null because its executing too early, you are telling me.

You dont want to halt your Unity thread. That would be terrible.

I believe the answer you are looking for is in this post

http://stackoverflow.com/questions/14827532/waiting-till-the-async-task-finish-its-work

which is simply to track the progress of your ASyncTask and flag in your plugin when that is complete. Only then perform the .Call.

There is lots of talk of the UI Thread so you may require the means of communicating with it. You may require the current Context