Say I'm using a HTTP requests library for downloading files. This library uses threads inside. Now, I want to wait on the main thread until other threads complete their execution.
All the other solutions that I found by googling only work if I have access to the Thread variables that were used in the library. But these are not accessible to me.
Here's what i'm using currently:
package smartzero.eightnoteight.testfirebase;
import com.firebase.client.AuthData;
import com.firebase.client.Firebase;
import com.firebase.client.FirebaseError;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("email: ");
        String email = in.nextLine();
        System.out.print("password: ");
        String password = in.nextLine();
        Firebase fb = new Firebase("https://nullform.firebaseio.com");
        fb.authWithPassword(email, password, new AuthResultHandler());
        try {
            Thread.sleep(1000000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    public static class AuthResultHandler implements Firebase.AuthResultHandler {
        @Override
        public void onAuthenticated(AuthData authData) {
            System.out.println("authentication successful");
            String uid = authData.getUid();
            new RunTests(uid);
        }
        @Override
        public void onAuthenticationError(FirebaseError firebaseError) {
            System.out.println("authentication failed.");
        }
    }
}
PS: i'm testing firebase using firebase-client-jvm on my pc.
 
     
     
     
     
    