Package org.jboss.remoting.callback

Examples of org.jboss.remoting.callback.BlockingCallbackStore



   public void testBlockingStore() throws Exception
   {

      final BlockingCallbackStore store = new BlockingCallbackStore();

      new Thread(new Runnable() {
         public void run()
         {
            for(int x = 0; x < 100; x++)
            {
               try
               {
                  store.add(new Holder(x));
               }
               catch (IOException e)
               {
                  failure = true;
                  e.printStackTrace();
               }
            }
         }
      }).start();

      new Thread(new Runnable() {
         public void run()
         {
            for(int i = 500; i < 600; i++)
            {
               try
               {
                  store.add(new Holder(i));
               }
               catch (IOException e)
               {
                  failure = true;
                  e.printStackTrace();
               }
            }
         }
      }).start();

      Thread.sleep(1000);

      Holder holder = (Holder)store.getNext();
      while(holder != null)
      {
         int num = holder.getNum();
         if(num <= 100)
         {
            System.out.println("lowCounter = " + lowCounter + ", num = " + num);
            assertEquals(lowCounter, num);
            lowCounter++;
         }
         else
         {
            System.out.println("highCounter = " + highCounter + ", num = " + num);
            assertEquals(highCounter, num);
            highCounter++;
         }
         Thread.sleep(100);
         holder = (Holder)store.getNext();
      }

      assertFalse(failure);

   }
View Full Code Here

TOP

Related Classes of org.jboss.remoting.callback.BlockingCallbackStore

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.