If your example should already be completed, no , you do not need to block or manage any critical section, since you are not changing anything.
But you, for example, an example, it is simply meaningless.
You do not need to handle concurrency when there are streams that just read simple data (different things in iterable data structures), but this is only useful when you have static data that does not need to be changed. As soon as you add only one writer, you you need to make sure that when he writes that no one is reading, but everyone will read at the same time as other readers, if not one writer does his job.
Jack
source share