E
E
Erik Mironov2020-08-10 10:02:01
Java
Erik Mironov, 2020-08-10 10:02:01

Different methods per thread or synchronized?

Let's say my program uses only 2-3 threads. There is a method marked synchronized. The question is, does it make sense to implement separate methods for each thread if there are few of them, or is it not accepted and has its own pitfalls, and is it better to use synchronized in one place?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Erik Mironov, 2020-08-10
@Erik_Mironov

I seem to have asked a very stupid question and only now I realized that it is stupid, because using a shared resource in different methods does not exempt from the need to use synchronized, and if there is no shared resource, then synchronized is not needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question