java - Should I explicitly wake a thread sucking on BlockingQueue.take() for performance? -


i understand having thread sucking elements of blockingqueue using take() method wait element available (unless interrupted).

i have 2 questions:

i) thread automatically woken-up element becomes available or there delay (i.e., thread checks later)?

ii) if there delay, make sense wake thread (by interrupting explicitly example)? thinking latency , performance.

there no additional delay. method call returns if element available or thread interrupted.

retrieves , removes head of queue, waiting if necessary until element becomes available.  returns:     head of queue  throws:     interruptedexception - if interrupted while waiting 

the blockinqueue doing automatically (impl. of arrayblockingqueue).

// in add etc. notempty.signal();  // in take() while(count == 0)    notempty.await(); 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -