Package net.pms.util

Examples of net.pms.util.TaskRunner


    }
  }

  @Test
  public void simpleScheduledTasks() throws InterruptedException {
    TaskRunner tk = new TaskRunner();

    final Counter c = new Counter();

    for (int i = 0; i < 3; i++) {
      tk.submitNamed("myTask", new Runnable() {
        @Override
        public void run() {
          c.incr();
        }
      });
    }
    tk.shutdown();
    tk.awaitTermination(1, TimeUnit.DAYS);
    assertEquals("all 3 task is executed", 3, c.x);
  }
View Full Code Here


    assertEquals("all 3 task is executed", 3, c.x);
  }

  @Test
  public void singletonTasks() throws InterruptedException {
    TaskRunner tk = new TaskRunner();

    final Counter c = new Counter();

    for (int i = 0; i < 5; i++) {
      tk.submitNamed("myTask", true, new Runnable() {
        @Override
        public void run() {
          sleep();
          c.incr();
        }
      });
    }
    tk.shutdown();
    tk.awaitTermination(1, TimeUnit.DAYS);
    assertEquals("only one task is executed", 1, c.x);
  }
View Full Code Here

    }
  }

  @Test
  public void simpleScheduledTasks() throws InterruptedException {
    TaskRunner tk = new TaskRunner();

    final Counter c = new Counter();

    for (int i = 0; i < 3; i++) {
      tk.submitNamed("myTask", new Runnable() {
        @Override
        public void run() {
          c.incr();
        }
      });
    }
    tk.shutdown();
    tk.awaitTermination(1, TimeUnit.DAYS);
    assertEquals("all 3 task is executed", 3, c.x);
  }
View Full Code Here

    assertEquals("all 3 task is executed", 3, c.x);
  }

  @Test
  public void singletonTasks() throws InterruptedException {
    TaskRunner tk = new TaskRunner();

    final Counter c = new Counter();

    for (int i = 0; i < 5; i++) {
      tk.submitNamed("myTask", true, new Runnable() {
        @Override
        public void run() {
          sleep();
          c.incr();
        }
      });
    }
    tk.shutdown();
    tk.awaitTermination(1, TimeUnit.DAYS);
    assertEquals("only one task is executed", 1, c.x);
  }
View Full Code Here

TOP

Related Classes of net.pms.util.TaskRunner

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.