I created a synchronized queue and use SyncLock in the SyncRoot property of this queue when calling Enqueue / Dequeue methods. Methods are called from instances of standard producer / consumer classes.
Is this the correct use of the SyncRoot property?
Would it be better to create a private shared object in each class and block it?
Please explain your arguments.
Yes, it is this property SyncRoot. In particular, this means that if another “wrapper” collection is created, it will probably use the same one SyncRoot, so everyone can synchronize correctly.
SyncRoot
, , , , . - , ? ?
, , Enqueue/Dequeue. , , , .
Source: https://habr.com/ru/post/1712462/More articles:Use ampersand in CAST in SQL - castingCreating a replica sql table - sqlHow to dynamically bind a socket to only one network interface? - c ++How to stop elements in ContextMenuStrip from processing ampersands specifically? - c #объединение двух таблиц с одинаковым столбцом в значение в один - sqlRemoving one item from the trash - c #CXF maven plugin generates classes in the wrong directory - maven-2OWASP Consider Restoring a New Session after Authentication or Privilege Level Success - sessionGridBagLayout Manager and Size Controls - javaAndroid database: problem with IllegalStateException - androidAll Articles