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.CopyOnWriteArraySet;

public class MainActivity extends AppCompatActivity {
    CopyOnWriteArraySet copyOnWriteArraySet;
    String head;

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

    }

}


