Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ArrayBlockingQueue #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Create ArrayBlockingQueue #69

wants to merge 1 commit into from

Conversation

djashan
Copy link

@djashan djashan commented Oct 9, 2023

import java.util.concurrent.ArrayBlockingQueue;

class Main {
public static void main(String[] args) {
ArrayBlockingQueue animals = new ArrayBlockingQueue<>(5);

    animals.add("Dog");
    animals.add("Cat");
    animals.add("Horse");
    System.out.println("ArrayBlockingQueue: " + animals);

    // Using remove()
    String element1 = animals.remove();
    System.out.println("Removed Element:");
    System.out.println("Using remove(): " + element1);

    // Using poll()
    String element2 = animals.poll();
    System.out.println("Using poll(): " + element2);

    // Using clear()
    animals.clear();
    System.out.println("Updated ArrayBlockingQueue: " + animals);
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant