All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jgroups.tests.bla10 Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.jgroups.tests;

import org.jgroups.ReceiverAdapter;
import org.jgroups.util.Util;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author Bela Ban
 * @since x.y
 */
public class bla10 extends ReceiverAdapter {
    protected Lock lock=new ReentrantLock();
    protected Condition cond=lock.newCondition();


    public static void main(String[] args) {
        new bla10().start();
    }

    private void start() {

        Thread waiter=new Thread(() -> {
            lock.lock();
            try {
                System.out.printf("waiting\n");
                cond.await();
                System.out.printf("done waiting\n");
            }
            catch(InterruptedException e) {
                e.printStackTrace();
            }
            finally {
                lock.unlock();
            }
        });



        // Util.sleep(1000);
        lock.lock();
        try {
            cond.signalAll();
        }
        finally {
            lock.unlock();
        }

        waiter.start();


    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy