java - Synchronize on BlockedQueue -


I have a code piece I'm reviewing (using).

Public Class Mayclass {... Private Blocked Questions q = New Link Blocking Questions & lt; MyData> (1000); Private stable final batch size = 1000; Public Boolean testing method () {Boolean = false; Synchronize (q) {if (q.size == batch size) {q.notify (); Did = true; }} Returned;

}

When I run FindBugs on this piece of code, then it complains that -

This method is a Object Synchronization is an example of a class from the Java.util.concurrent package (or its subclasses). Examples of these classes have a unified control mechanism that are different and incompatible with the use of keyword synchronization.

If I synchronize the code piece synchronize (q) {<>>, it complains -

call this method to the object . Note () or Object NotifyAll () without placing the lock on the object. Notify calling () or notify () lock without any lock in the monitorstate appointment

How do I apply this method so that it can pass FindBugs verification? Is the above mentioned implementation appropriate for notification in cases for concurrent sections?

Thank you.

notify () wait () And should not be used with classes of java.util.concurrent .

Blocking quizzes uses an internal mechanism to block a put () if there is no space for more elements or poll () But if no element consumes it. You do not care about it.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -