@Test
  public void testThreadSafety() throws InterruptedException {
    BoundedList<Integer> boundedList = getBoundedListForTest();

    Thread thread1 = new Thread(new Runnable() {
      @Override
      public void run() {
        for (int i = 1; i <= 100; i++) {
          boundedList.add(i);
        }
      }
    });

    Thread thread2 = new Thread(new Runnable() {
      @Override
      public void run() {
        for (int i = 1; i <= 100; i++) {
          boundedList.add(i);
        }
      }
    });

    thread1.start();
    thread2.start();

    thread1.join(THREAD_TEST_TIMEOUT.toMillis());
    thread2.join(THREAD_TEST_TIMEOUT.toMillis());

    Assert.assertTrue("BoundedList should have the last 10 values", boundedList.getValues().size() == 10);
    for (Integer gaugeValue : boundedList.getValues()) {
      Assert.assertTrue("Values should have the last 10 range", gaugeValue <= 100 && gaugeValue > 90);
    }
  }
Class to encapsulate test-cases for {@link BoundedList}
samza-core/src/test/scala/org/apache/samza/metrics/TestBoundedList.java