Package org.jgroups.util

Examples of org.jgroups.util.ReusableThread


    private final Object block_sending=new Object();

    private int _windowsize_cap=1000000; //initial window size can not be more than 10^6 messages.

    public FLOW_CONTROL() {
        _reusableThread=new ReusableThread(FLOW_CONTROL);
    }
View Full Code Here





    public void testReusableThread() {
        ReusableThread t=new ReusableThread("Demo ReusableThread");
        MyThread m1=new MyThread(1);
        MyThread m2=new MyThread(2);

        LongRunningThread m4=new LongRunningThread(4);

        System.out.println("Assigning task");
        t.assignTask(m4);

        System.out.println("Sleeping 2 secs");
        Util.sleep(2000);

        System.out.println("stop()");
        t.stop();
        System.out.println("stop() -- done");

        Util.printThreads();

        System.out.println("\nAssigning task 1");
        t.assignTask(m1);
        t.waitUntilDone()// passive wait
        System.out.println("done with task 1");

        Util.printThreads();

        System.out.println("\nAssigning task 2");
        t.assignTask(m2);
        t.waitUntilDone();
        System.out.println("done with task 2");

        System.out.println("Stopping thread");
        t.stop();
        System.out.println("done");

        Util.printThreads();
    }
View Full Code Here

        Util.printThreads();
    }


    public void testAssignMultipleTimes() {
        ReusableThread t=new ReusableThread("Demo ReusableThread");

        LongRunningThread t1, t2;
        t1=new LongRunningThread(1, 500);
        t2=new LongRunningThread(2, 300);

        t.start();

        t.assignTask(t1);
        t.waitUntilDone();
        assertTrue(t.done());
        t.assignTask(t2);
        t.waitUntilDone();
        assertTrue(t.done());
    }
View Full Code Here

        t.waitUntilDone();
        assertTrue(t.done());
    }

    public void testStop() {
        ReusableThread t=new ReusableThread("Demo ReusableThread");

        LongRunningThread t1;
        t1=new LongRunningThread(1, 20000);

        t.assignTask(t1);
        Util.sleep(1000);
        t.stop();
        t.waitUntilDone();
        assertTrue(t.done());
        assertFalse(t.isAlive());
    }
View Full Code Here

   

    public static void main(String[] args) {
  ThreadPool      pool=new ThreadPool(5);
  ReusableThread  t;
  MyThread        my=new MyThread(1);
  int             i=0;

  while(true) {
      t=pool.getThread();
      my.num=i++;

      if(t != null) {
    System.out.println("Assigning task");
    t.assignTask(my);
    Util.sleep(100);
      }
      else {
    System.out.println("Waiting a bit for threads to become available...");
    Util.sleep(1000);
View Full Code Here




    public void testReusableThread() {
        ReusableThread t=new ReusableThread("Demo ReusableThread");
        MyThread m1=new MyThread(1);
        MyThread m2=new MyThread(2);

        LongRunningThread m4=new LongRunningThread(4);

        System.out.println("Assigning task");
        t.assignTask(m4);

        System.out.println("Sleeping 2 secs");
        Util.sleep(2000);

        System.out.println("stop()");
        t.stop();
        System.out.println("stop() -- done");

        Util.printThreads();

        System.out.println("\nAssigning task 1");
        t.assignTask(m1);
        t.waitUntilDone()// passive wait
        System.out.println("done with task 1");

        Util.printThreads();

        System.out.println("\nAssigning task 2");
        t.assignTask(m2);
        t.waitUntilDone();
        System.out.println("done with task 2");

        System.out.println("Stopping thread");
        t.stop();
        System.out.println("done");

        Util.printThreads();
    }
View Full Code Here

        Util.printThreads();
    }


    public void testAssignMultipleTimes() {
        ReusableThread t=new ReusableThread("Demo ReusableThread");

        LongRunningThread t1, t2;
        t1=new LongRunningThread(1, 500);
        t2=new LongRunningThread(2, 300);

        t.start();

        t.assignTask(t1);
        t.waitUntilDone();
        assertTrue(t.done());
        t.assignTask(t2);
        t.waitUntilDone();
        assertTrue(t.done());
    }
View Full Code Here

        t.waitUntilDone();
        assertTrue(t.done());
    }

    public void testStop() {
        ReusableThread t=new ReusableThread("Demo ReusableThread");

        LongRunningThread t1;
        t1=new LongRunningThread(1, 20000);

        t.assignTask(t1);
        Util.sleep(1000);
        t.stop();
        t.waitUntilDone();
        assertTrue(t.done());
        assertFalse(t.isAlive());
    }
View Full Code Here

    private final Object block_sending=new Object();

    private int _windowsize_cap=1000000; //initial window size can not be more than 10^6 messages.

    public FLOW_CONTROL() {
        _reusableThread=new ReusableThread(FLOW_CONTROL);
    }
View Full Code Here

TOP

Related Classes of org.jgroups.util.ReusableThread

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.