I am implementing a very simple synchronized In fact when a thread wants dequeue (polling) if the queue is empty, then it will have to wait until another thread, anu, and vice versa if the queue is full, / P> I'm not very good at detecting deadlock prone codes, do you think this is likely to be a deadlock? There are several problems with your implementation: This last point stops progressing permanently from malicious users of your queue by not synchronizing them on the queue object, not releasing the lock. circular line , as my Is it possible to
deadlock ! But I do not believe that,
Import java.util.ArrayList; Square circular quiz & lt; T & gt; {ArrayList & lt; T & gt; Q; Integer, back, shape; Public circular qu (int size) {q = new arreelist & lt; T & gt; (); For (int i = 0; i
Notify () calls should come from inside the
synchronize block
poll () to
null .
ArrayList & lt; No need to use T & gt; and fill it with
null s; The plain array of the
object will suffice, you will need to add castings, but it is happening with or without
ArrayList so that you can take it to your code.
No comments:
Post a Comment