Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

395
Views
How to convert asynchronous call to synchronous for firebase access Amazon web service Lambda function in java

I want to call a AWS lambda function within which I am connecting to a Firebase database. The problem is that the handler executes before I get the needed data from Firebase.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

A recipe to convert an asynchronous call into a synchronous one:

Let's assume the async call is called fooAsync(), and that you have some way to check a result condition when the operation is completed. You can introduce your own volatile boolean fooComplete to track this.

Then:

public void fooSyncWrapper() {
    volatile boolean fooComplete = false;

    Thread thread = new Thread() {
        @Override
        public void run() {
            fooAsync();

            while (!fooComplete) {
                // busy wait on completion condition
                fooComplete = checkIfComplete();
            }

            // task is completed, thread will join
        }
    };

    thread.start();
    thread.join();
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!