How to pause a thread until a certain event?

I have a thread. It is necessary at some point to stop and wait until there is some event (or rather, not add some kind of element in the HashMap, add is in other threads)

Tell me, how is this usually done? Yuzayu Java 8 + Spring

Thanks in advance!
June 14th 19 at 20:05
2 answers
June 14th 19 at 20:07
First, it is possible that the answer is in the question. The Spring is a high-level of abstraction, eliminating in many cases the need for explicit threading events and asynchronous methods. Second, as already written there are many ways to synchronize threads, to give the correct answer, you must know your algorithm. Maybe you need CyclicBarrier, and maybe more efficient HashMap to replace BlockingQueue \_(ツ)_/
June 14th 19 at 20:09
Googly about the Object wait/notify, ConcurrentHashMap, and all that jazz. In General, Spring is definitely not for you if you such basic things still do not understand. Learn the basics first.
Do such low-level stuff is a good solution? I thought that a synchronizer (java.util.concurrent) for such yuzayut...

In with Spring more or less managed. But you're right, in some areas, basic knowledge is not enough - moved recently from PHP. - Freeman.Stark80 commented on June 14th 19 at 20:12
The goodness of the solution depends on the task. c the synchronized wait/notify is more low-level compared to java.util.concurrent wait/notify is not prohibited or deprecated APIs. It's a DIFFERENT API. To understand which API optimally, it is important for the pros. - Larr commented on June 14th 19 at 20:15

Find more questions by tags Java