Hello,
This issue is caused by your code not meeting the execution conditions of the notify()
or notifyAll()
methods.
You could find the following conditions via referring to the official documentation: notify.
This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:
By executing asynchronized
instance method of that object.
By executing the body of asynchronized
statement that synchronizes on the object.
For objects of typeClass
, by executing a synchronized static method of that class.
Therefore, you need to lock the object it before calling NotifyAll()
in C#.
Please refer to lock statement (C# reference) to get more details.
Update:
This should be due to an error thrown by the compiler.
When you use the RecycleView.Adapter, if the adapter gets an address different from the actual address when initializing, the adapter mistakenly thinks that there are multiple different threads operating it, which will cause this error to cause no matter what object we lock.
In fact, the use case of notifyall is not for data updates, but for waking up threads, see:
The
notifyAll()
method of thread class is used to wake up all threads. This method gives the notification to all waiting threads of a particular object.
Please use the notifyDataSetChanged method to update the dataset, it is the most recommended way to do it.
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.