---
title: "Comment by Artem Abeleshev on \"How I implemented Multithreading and reduced my API time from 4s to <100ms\" | Hashnode"
description: "How I implemented Multithreading and reduced my API time from 4s to &lt;100ms Note that &quot;speed-up&quot; of the API comes with the price of the result obtai"
url: "https://hashnode.com/posts/implementing-multithreading-and-reduced-api-response-time/61fcf9acfd8b083e5728a6dd/comment/61fd383e8d15cb3e7ce6112c"
---

[Discussion](https://hashnode.com/posts/implementing-multithreading-and-reduced-api-response-time/61fcf9acfd8b083e5728a6dd)

Comment [How I implemented Multithreading and reduced my API time from 4s to <100ms](https://hashnode.com/posts/implementing-multithreading-and-reduced-api-response-time/61fcf9acfd8b083e5728a6dd)

[Artem Abeleshev](https://hashnode.com/@tyoma)

[Feb 4, 2022](https://hashnode.com/posts/implementing-multithreading-and-reduced-api-response-time/61fcf9acfd8b083e5728a6dd/comment/61fd383e8d15cb3e7ce6112c)

> How I implemented Multithreading and reduced my API time from 4s to <100ms

Note that "speed-up" of the API comes with the price of the result obtaining. In you case you just get rid of blocking call delegating it to other thread (fire-and-forget). If the result is needed you will need a polling system with storing async id or similar.

Spring's async support made for more general idea, it is about to bring full scale async support to platform hiding the complexity of the Future facility. Async idea is about to minimise thread blocking and more fare resource managing (task spliting, job stealing). Also Spring take care of thread locals propagations (for example, security context).

> We can achieve the above said in the following ways:

Also locks. Locks are much more preferable than syncronize blocks/methods as they are using CaS instructions.

[Pratham Krishna](https://hashnode.com/@prathamkrishna)

[Feb 13, 2022](https://hashnode.com/posts/implementing-multithreading-and-reduced-api-response-time/61fcf9acfd8b083e5728a6dd/comment/61fd383e8d15cb3e7ce6112c#reply-620892c0d59187113c4c1701)

Hey! yes you're right! There are actually tons of options to pick from, you could use a reactive programming paradigm; you could use Future as you said. Again, on an already existing system, it would be better to use a Future/Completable-Future workaround. I'll have to read a bit on locks and the CaS instructions, thanks for that!

[Pratham Krishna](https://hashnode.com/@prathamkrishna)

[Feb 13, 2022](https://hashnode.com/posts/implementing-multithreading-and-reduced-api-response-time/61fcf9acfd8b083e5728a6dd/comment/61fd383e8d15cb3e7ce6112c#reply-62089809d59187113c4c17c4)

also, on a side note: imo multithreading should be the last approach one should go for
