How expensive is synchronization?

I am writing a network application using java.nio api. My plan is to do I / O on one thread and handle events on another. To do this, I need to synchronize the read / write so that the race condition is never fulfilled.

Given that I need to process thousands of connections at the same time, is synchronization worth it, or should I use a single thread to handle I / O and events?

+3
source share
2 answers

What kind of event handling are you doing? Where is the likely bottleneck? Do you even have a bottleneck?

Start with the simplest implementation and optimize bottlenecks as soon as you know them.

, IO , , , .

, , . - , , .

.

, , , .

+3

, , .

0

Source: https://habr.com/ru/post/1741313/


All Articles