<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://medjava.ro/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://medjava.ro/feed.php">
        <title>Med Java - java:threads</title>
        <description></description>
        <link>https://medjava.ro/</link>
        <image rdf:resource="https://medjava.ro/lib/exe/fetch.php?media=wiki:dokuwiki.svg" />
       <dc:date>2026-04-26T14:11:42+00:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:atomic-variables&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:concurrent-binary-tree&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:cyclic-barrier-example&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:cyclic-barrier-parallel-vector-sum&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:dining-philosophers&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:hello-world&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:join-wait-for-thread-to-finish&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:multiple-producers-and-consumers&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:readers-writers-conditional-synchronization&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:readers-writers-mutual-exclusion&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:replicated-workers-executor-service&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:replicated-workers-fork-join-pool&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:semaphore-example&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:send-parameters-retrieve-results&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:sleeping-barber&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:synchronized-bank-account&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:synchronized-example&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:volatile-usage&amp;rev=1735842138&amp;do=diff"/>
                <rdf:li rdf:resource="https://medjava.ro/doku.php?id=java:threads:wait-notify-producer-consumer&amp;rev=1735842138&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://medjava.ro/lib/exe/fetch.php?media=wiki:dokuwiki.svg">
        <title>Med Java</title>
        <link>https://medjava.ro/</link>
        <url>https://medjava.ro/lib/exe/fetch.php?media=wiki:dokuwiki.svg</url>
    </image>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:atomic-variables&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>atomic-variables</title>
        <link>https://medjava.ro/doku.php?id=java:threads:atomic-variables&amp;rev=1735842138&amp;do=diff</link>
        <description>Atomic Variables in Java Threads

Atomic variables in Java, provided by the java.util.concurrent.atomic package, are used for operations that need to be performed atomically to avoid thread interference without using synchronization. They are often used in concurrent programming where multiple threads need to modify a shared variable reliably.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:concurrent-binary-tree&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>concurrent-binary-tree</title>
        <link>https://medjava.ro/doku.php?id=java:threads:concurrent-binary-tree&amp;rev=1735842138&amp;do=diff</link>
        <description>Concurrent Binary Tree using Java Threads

Implementing a thread-safe binary tree in Java where each node has its own lock can be an efficient solution for concurrent insertions. 

This approach allows multiple threads to work on different parts of the tree simultaneously, reducing contention compared to a global lock for the entire tree.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:cyclic-barrier-example&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>cyclic-barrier-example</title>
        <link>https://medjava.ro/doku.php?id=java:threads:cyclic-barrier-example&amp;rev=1735842138&amp;do=diff</link>
        <description>Cyclic Barrier Example in Java Threads

The CyclicBarrier in Java is a synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point. It is useful in scenarios where you have a parallel task that can be divided into smaller, independent tasks, and you need to wait for all the smaller tasks to complete before proceeding.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:cyclic-barrier-parallel-vector-sum&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>cyclic-barrier-parallel-vector-sum</title>
        <link>https://medjava.ro/doku.php?id=java:threads:cyclic-barrier-parallel-vector-sum&amp;rev=1735842138&amp;do=diff</link>
        <description>Using CycleBarrier to compute the vector sum in parallel

Imagine you have a large dataset divided into segments, and you want to process each segment in parallel. After processing each segment, you might need to combine the results before proceeding.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:dining-philosophers&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>dining-philosophers</title>
        <link>https://medjava.ro/doku.php?id=java:threads:dining-philosophers&amp;rev=1735842138&amp;do=diff</link>
        <description>Dining Philosophers - Java Thread Problem

The Dining Philosophers problem is a classic synchronization problem that demonstrates the challenges of avoiding deadlock while managing shared resources. 

In this problem, five philosophers sit around a table and do two things: think and eat. However, they need two forks to eat, and there are only five forks placed between them. The challenge is to design a protocol that allows the philosophers to eat without ever starving (each can eventually eat) a…</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:hello-world&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>hello-world</title>
        <link>https://medjava.ro/doku.php?id=java:threads:hello-world&amp;rev=1735842138&amp;do=diff</link>
        <description>Java Threads Hello World Example

Extending Thread


// Import necessary classes
import java.lang.Thread;

// HelloWorldThread class extending the Thread class
public class HelloWorldThread extends Thread {

    @Override
    public void run() {
        // This code will be executed in a separate thread
        System.out.println(&quot;Hello, World from a thread!&quot;);
    }

    public static void main(String[] args) {
        // Create a new instance of the HelloWorldThread
        HelloWorldThread my…</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:join-wait-for-thread-to-finish&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>join-wait-for-thread-to-finish</title>
        <link>https://medjava.ro/doku.php?id=java:threads:join-wait-for-thread-to-finish&amp;rev=1735842138&amp;do=diff</link>
        <description>Using join method to wait for a thread to finish in java threads

Demonstrates waiting for the completion of a thread&#039;s execution using the join method.


public class ThreadJoin {

    public static void main(String[] args) throws InterruptedException {
        // Creating a new thread
        Thread thread = new Thread(() -&gt; {
            try {
                // Simulating a task that takes one second
                Thread.sleep(1000);
                System.out.println(&quot;Thread finished its …</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:multiple-producers-and-consumers&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>multiple-producers-and-consumers</title>
        <link>https://medjava.ro/doku.php?id=java:threads:multiple-producers-and-consumers&amp;rev=1735842138&amp;do=diff</link>
        <description>Multiple Producers and Consumers Problem using Java Threads

The Producer-Consumer problem with multiple producers and consumers involves managing a shared resource (like a buffer or queue) where producers add items to the resource and consumers remove them.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:readers-writers-conditional-synchronization&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>readers-writers-conditional-synchronization</title>
        <link>https://medjava.ro/doku.php?id=java:threads:readers-writers-conditional-synchronization&amp;rev=1735842138&amp;do=diff</link>
        <description>Readers-Writers Problem in Java Threads Using Conditional Synchronization

Conditional synchronization is a technique used to control the access to shared resources based on certain conditions. This approach is often used in scenarios like the Readers-Writers problem, where the conditions for accessing shared data vary depending on whether the accessing thread is a reader or a writer.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:readers-writers-mutual-exclusion&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>readers-writers-mutual-exclusion</title>
        <link>https://medjava.ro/doku.php?id=java:threads:readers-writers-mutual-exclusion&amp;rev=1735842138&amp;do=diff</link>
        <description>Readers-Writers Problem in Java Threads Using Mutual Exclusion

The Readers-Writers problem is a classic example of synchronization challenge in computer science, which deals with a situation where many threads try to read from a shared data area while others try to write to it.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:replicated-workers-executor-service&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>replicated-workers-executor-service</title>
        <link>https://medjava.ro/doku.php?id=java:threads:replicated-workers-executor-service&amp;rev=1735842138&amp;do=diff</link>
        <description>Replicated Workers using ExecutorService in Java Threads

The Replicated Workers model in Java is a concurrency design pattern where multiple worker threads (or tasks) perform the same operation in parallel on different data. This model is particularly useful for scenarios where a large task can be divided into smaller, independent subtasks.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:replicated-workers-fork-join-pool&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>replicated-workers-fork-join-pool</title>
        <link>https://medjava.ro/doku.php?id=java:threads:replicated-workers-fork-join-pool&amp;rev=1735842138&amp;do=diff</link>
        <description>Replicated Workers using ForkJoinPool in Java Threads

Utilizing Java&#039;s ForkJoinPool is a great approach for parallelizing tasks that can be broken down into smaller, recursive pieces. 

It&#039;s especially effective for computational tasks that benefit from a divide-and-conquer strategy.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:semaphore-example&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>semaphore-example</title>
        <link>https://medjava.ro/doku.php?id=java:threads:semaphore-example&amp;rev=1735842138&amp;do=diff</link>
        <description>Using Semaphore in Java Threads

Semaphores in Java, provided by the java.util.concurrent package, are used to control access to a shared resource by multiple threads. 
They can be used to implement resource pools or to impose a bound on a collection. A common use case is limiting the number of concurrent threads accessing a particular resource.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:send-parameters-retrieve-results&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>send-parameters-retrieve-results</title>
        <link>https://medjava.ro/doku.php?id=java:threads:send-parameters-retrieve-results&amp;rev=1735842138&amp;do=diff</link>
        <description>Send parameters to a thread and retrieve results from it in Java threads

To send parameters to a thread and retrieve results from it in Java, you typically use the Callable interface and Future objects. 

The Callable interface is similar to Runnable, but it can return a value and throw exceptions.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:sleeping-barber&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>sleeping-barber</title>
        <link>https://medjava.ro/doku.php?id=java:threads:sleeping-barber&amp;rev=1735842138&amp;do=diff</link>
        <description>Sleeping Barber - Java Threads Problem

The Sleeping Barber problem is another classic synchronization problem. It involves a barber shop with a barber, a barber chair, and a waiting room with a number of chairs in it. 
If there are no customers, the barber goes to sleep. If a customer arrives and the barber is asleep, they wake the barber up.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:synchronized-bank-account&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>synchronized-bank-account</title>
        <link>https://medjava.ro/doku.php?id=java:threads:synchronized-bank-account&amp;rev=1735842138&amp;do=diff</link>
        <description>Synchronized Usage - Bank Account Concrete Example

In many scenarios, especially when working with shared data across multiple threads, synchronization is crucial to avoid concurrency issues such as race conditions. 

A classic example is managing a shared bank account where multiple threads try to update the account balance.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:synchronized-example&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>synchronized-example</title>
        <link>https://medjava.ro/doku.php?id=java:threads:synchronized-example&amp;rev=1735842138&amp;do=diff</link>
        <description>Synchronized keyword - example of usage


public class SynchronizedExample {
    // Synchronized method on the instance (this)
    public synchronized void syncMethodOnInstance() {
        // Code that is synchronized on the current instance
        System.out.println(&quot;Synchronized on the instance (this)&quot;);
    }

    // Synchronized block on the instance (this)
    public void syncBlockOnInstance() {
        synchronized (this) {
            // Code that is synchronized on the current instance
…</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:volatile-usage&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>volatile-usage</title>
        <link>https://medjava.ro/doku.php?id=java:threads:volatile-usage&amp;rev=1735842138&amp;do=diff</link>
        <description>Volatile usage in java threads

The volatile keyword in Java is used to indicate that a variable&#039;s value will be modified by different threads. It ensures that the value of the volatile variable will always be read from the main memory, not from the thread&#039;s cache memory. This is important for ensuring visibility of changes made by one thread to other threads.</description>
    </item>
    <item rdf:about="https://medjava.ro/doku.php?id=java:threads:wait-notify-producer-consumer&amp;rev=1735842138&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-01-02T18:22:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>wait-notify-producer-consumer</title>
        <link>https://medjava.ro/doku.php?id=java:threads:wait-notify-producer-consumer&amp;rev=1735842138&amp;do=diff</link>
        <description>Usage of wait and notify in Producer - Consumer problem

In Java, wait, notify, and notifyAll are methods used for inter-thread communication. They are part of the Object class and are used to coordinate activities between threads.

In this example, we&#039;ll create a simple</description>
    </item>
</rdf:RDF>
