- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
ArrayBlockingQueue put() method in Java
The put() method of the ArrayBlockingQueue class inserts the specified element at the tail of this queue. It waits for the space to become available, if the queue is full.
The syntax is as follows:
void put(E e)
Here, e is the element to be inserted.
To work with ArrayBlockingQueue class, you need to import the following package:
import java.util.concurrent.ArrayBlockingQueue;
The following is an example to implement put() method of Java ArrayBlockingQueue class:
Example
import java.util.concurrent.ArrayBlockingQueue; public class Demo { public static void main(String[] args) throws InterruptedException { ArrayBlockingQueue<Integer> q = new ArrayBlockingQueue<Integer>(7); q.put(200); q.put(310); q.put(400); q.put(450); q.put(500); q.put(550); q.put(700); System.out.println("ArrayBlockingQueue = " + q); } }
Output
ArrayBlockingQueue = [200, 310, 400, 450, 500, 550, 700]
Advertisements