ConcurrentLinkedQueue क्या है?
ConcurrentLinkedQueue एक अनबाउंडेड थ्रेड-सेफ कतार है जो लिंक्ड नोड्स (linked nodes) पर आधारित है। यह FIFO (First-In-First-Out) क्रम का पालन करती है। एकाधिक थ्रेड्स सुरक्षित रूप से कतार के तत्वों तक पहुंच सकते हैं। यह नल (null) मानों की अनुमति नहीं देती।
उदाहरण: ConcurrentLinkedQueue का उपयोग
यह उदाहरण दर्शाता है कि Android में ConcurrentLinkedQueue का उपयोग कैसे करें।
चरण 1: नया प्रोजेक्ट बनाएं
Android Studio में File → New Project चुनें।
चरण 2: लेआउट फ़ाइल (res/layout/activity_main.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="https://schemas.android.com/apk/res/android"
xmlns:app="https://schemas.android.com/apk/res-auto"
xmlns:tools="https://schemas.android.com/tools"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<TextView
android:id="@+id/actionEvent"
android:textSize="40sp"
android:layout_marginTop="30dp"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</LinearLayout>
चरण 3: MainActivity.java में कोड
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.widget.TextView;
import java.util.concurrent.ConcurrentLinkedQueue;
public class MainActivity extends AppCompatActivity {
ConcurrentLinkedQueue<String> concurrentLinkedQueue;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
concurrentLinkedQueue = new ConcurrentLinkedQueue<>();
final TextView actionEvent = findViewById(R.id.actionEvent);
// तत्व जोड़ना (FIFO क्रम में)
concurrentLinkedQueue.add("sai");
concurrentLinkedQueue.add("ram");
concurrentLinkedQueue.add("krishna");
concurrentLinkedQueue.add("prasad");
concurrentLinkedQueue.add("ram");
actionEvent.setText("" + concurrentLinkedQueue);
}
}
ऐप चलाएं
अपने Android डिवाइस को कनेक्ट करें और ऐप चलाएं। डिफ़ॉल्ट स्क्रीन पर कतार के तत्व FIFO क्रम में प्रदर्शित होंगे।

मुख्य बिंदु
- ConcurrentLinkedQueue लॉक-फ्री (lock-free) एल्गोरिदम का उपयोग करती है।
- यह FIFO क्रम बनाए रखती है।
- नल (null) तत्वों की अनुमति नहीं देती।
- उच्च समवर्ती (high concurrency) वातावरण के लिए उपयुक्त।