package com.example.myapplication;

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

import java.util.concurrent.PriorityBlockingQueue;

public class MainActivity extends AppCompatActivity {
    PriorityBlockingQueue priorityBlockingQueue;

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        priorityBlockingQueue = new PriorityBlockingQueue();
        final TextView actionEvent = findViewById(R.id.actionEvent);
        priorityBlockingQueue.add("sai");
        priorityBlockingQueue.add("ram");
        priorityBlockingQueue.add("krishna");
        priorityBlockingQueue.add("prasad");
        priorityBlockingQueue.add("ram");
        actionEvent.setText("" + priorityBlockingQueue);
        actionEvent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                actionEvent.setText("" + priorityBlockingQueue.poll());
            }
        });

    }

}


