package com.example.myapplication;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import java.util.concurrent.ArrayBlockingQueue;

public class MainActivity extends AppCompatActivity {
    ArrayBlockingQueue arrayBlockingQueue;
    String head;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        arrayBlockingQueue= new ArrayBlockingQueue<>(50);
        final TextView actionEvent = findViewById(R.id.actionEvent);
        arrayBlockingQueue.add("sai");
        arrayBlockingQueue.add("ram");
        arrayBlockingQueue.add("krishna");
        arrayBlockingQueue.add("prasad");
        actionEvent.setText("" + arrayBlockingQueue);
       actionEvent.setOnClickListener(new View.OnClickListener() {
           @SuppressLint("SetTextI18n")
           @Override
           public void onClick(View v) {
               try {
                   head= (String) arrayBlockingQueue.take();
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
               actionEvent.setText("" + arrayBlockingQueue);
           }
       });


    }

}


