in Education by
As I understand it, if there are only messages with a timestamp for the future in a MessageQueue, the MessageQueue blocks the Looper's loop until that time arrived. But this mechanism also works if the MessageQueue is completely empty and waiting for new input. How does the thread know how long to sleep / when to wake up in this case? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Threads have a "wait-notify" mechanism. When the thread is waiting, it's effectively sleeping. Once it's notified, it awakens and gets back to work. Implementations of BlockingQueue make the polling threads wait if there are no items to serve, and notify all the sleeping threads when a new item is inserted. These threads then awaken and can take the newly inserted item. More info about this mechanism can be found here (or by googling).

Related questions

0 votes
    In the buffer where there is no space for another block, the block can be inserted using (a) ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    If no header is specified, the block is said to be an _______________ PL/SQL block. (a) Strong (b ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    What are you going to do if there is no Functional Spec or any documents related to the system and developer who wrote ... company anymore, but you have a system and need to test?...
asked Oct 17, 2020 in Technology by JackTerrance
0 votes
    If a Replica stays out of the ISR for a long time, what does it signify?...
asked Nov 1, 2020 by JackTerrance
0 votes
    The strategy used to ensure that the message is a multiple of the cipher block size without compromising the size ... 1)Ciphertext stealing (2)Padding (3)Refactoring (4)Diffusion...
asked Mar 19, 2021 in Technology by JackTerrance
0 votes
    ____ allows you to loop through a block of code as long as the specified condition is true. 1. Tag 2. While 3. For...
asked Feb 24, 2021 by JackTerrance
+1 vote
    ____ allows you to loop through a block of code as long as the specified condition is true. a)Tag b)While c)For...
asked Oct 8, 2020 in Technology by JackTerrance
0 votes
    A network will be useful only if, it leads to equilibrium state at which there is no change of state? ( ... Synaptic Dynamics of Neural Networks Please answer the above question....
asked Sep 5, 2022 in Education by JackTerrance
0 votes
    What is it called if an object has its own lifecycle and there is no owner? (a) Aggregation (b) ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    Can anyone tell me how long does it take to learn Machine Learning? Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me how long does it take to become a Full Stack Developer? Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    A train 150 m long is running at a speed of 68 kmph. How long does it take to pass a man who is running at 8 kmph in the same ... the train? A. 5 sec B. 9 sec C. 12 sec D. 15 sec...
asked Feb 19, 2021 in Education by JackTerrance
0 votes
    There are situations in which it is necessary to write back the block to disk, even though the buffer ... Buffer in chapter Storage and File Structures of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    I am retrieving messages from an Outlook account. I am trying to get inline files and attachments from ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    What does it mean by message blocking is active on iphone?...
asked Aug 6, 2022 in Technology by Editorial Staff
...