---
title: "Artem Abeleshev (@tyoma) | Hashnode"
description: "Artem Abeleshev (@tyoma) writes on Hashnode. Read their latest articles and follow their work."
url: "https://hashnode.com/@tyoma"
---

@tyoma

# Artem Abeleshev

@tyoma · Joined December 2021

## Comments

[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.](https://hashnode.com/posts/implementing-multithreading-and-reduced-api-response-time/61fcf9acfd8b083e5728a6dd/comment/61fd383e8d15cb3e7ce6112c)

Comment · Article · Feb 4, 2022 · [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)

[Builders usually used to built immutable objects. Like you mentioned it is possible to use constructors for this purposes. But builders come handy when your immutable object contains a bunch of optional fields. In case of constructors you will end up with telescoping constructors. Exposing an all args constructor is a bad practice if you have quite a bunch of fields (usually more than 6), it looks bad and bulky. This is where builder pattern come to rescue. Problem of inconsistent object is not a problem of the builder usage, it is a probem of the object itself. You will anyway end up applying some checks if state of your object depends on the args values. Even the required fields can be passed as null that is equivalent to not setting them at all. Builder has nothing to do with that. If some invalid parameter passed, an IllegalArgumentException should be thrown. You can make it either in construction, or in a build method of builder. If you want to guarantee that some mandatory args will be always indicated by caller, you can make builder constructor to accept them. I usually do private constructor for builder and add static factory method for builder itself: public static class Builder { public static Builder of(Integer arg1, String arg2) { return new Builder(arg1, arg2); } private Integer arg1; private String arg2; private Foo arg3; private Bar arg4; private Builder(Integer arg1, String arg2) { this.arg1 = arg1; this.arg2 = arg2; } // other builder methods }](https://hashnode.com/posts/object-construction-in-java/61cc9ca2351cb236ddfb6ccc/comment/61cd823abf68083702212ecd)

Comment · Article · Dec 30, 2021 · [Object construction in Java](https://hashnode.com/posts/object-construction-in-java/61cc9ca2351cb236ddfb6ccc)
