Blockingqueue: Queue (FIFO)

Source: Internet
Author: User




Blockingqueue: Queue (FIFO)

Blocking queues:

Non-blocking queue:

Arrayblockingqueue: Blocking queues

1, add (object): Adds an object to the queue if the queue can

Holds, returns true, otherwise throws an exception

2. Offer (object): Indicates that if possible, add an object to the

In the queue, if it can be put in, return true, otherwise, return false

3. Put (object): Joins the object to the queue if the queue does not have

Space, the thread that called the secondary method is blocked until there is space in the queue to continue

4. Poll (time): Takes the Element object in the first row of the queue, if

Queue is empty, you can wait for a given time, not an element, and return null

5. Take (): Takes the first element object in the queue, if the queue is empty

Block the thread that called the method until there are elements added to the queue











Blockingqueue: Queue (FIFO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.