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

173
Views
Multithreading in spring boot controller

Following is the code in one of my spring controller.In this I need to store some data in postgres database with multithreading so I don't have wait until it saves data into database and I can send response back to called API.How can I achieve this?

//billingLogService.saveBillingLogDetails(Object);
if (!Util.isNull(personId) && !Util.isNull(personConnectionData)) {
    return new Callable<Map<Long, PersonConnectionTo>>() {
        @Override
        public Map<Long, PersonConnectionTo> call() throws Exception {
            Map<Long, PersonConnectionTo> connectionTextMap =
                profileService.getconnectionTextForFocusCompany(focusCompanyId, personId, personConnectionData);
            return connectionTextMap;
        }
    };
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

One of the ways to do is put the whole logic(which you want to run in a separate thread) into a method of some service class.
Then
1. Annotate class with @Service or equivalent.
2. Annotate method with @Async
3. Use @EnableAsync
That should suffice

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!