Class Blitzer


  • public class Blitzer
    extends java.lang.Object
    A class that "blitzes" an object by calling it many times, from multiple threads. Used for stress-testing synchronisation.
    • Constructor Summary

      Constructors 
      Constructor Description
      Blitzer​(int actionCount)  
      Blitzer​(int actionCount, int threadCount)  
      Blitzer​(int actionCount, int threadCount, java.util.concurrent.ThreadFactory threadFactory)  
      Blitzer​(int actionCount, java.util.concurrent.ExecutorService executorService)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void blitz​(long timeoutMs, java.lang.Runnable action)  
      void blitz​(java.lang.Runnable action)  
      void shutdown()  
      private java.util.concurrent.CountDownLatch spawnThreads​(java.lang.Runnable action)  
      int totalActionCount()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_THREAD_COUNT

        public static final int DEFAULT_THREAD_COUNT
        The default number of threads to run concurrently.
        See Also:
        Constant Field Values
      • executorService

        private final java.util.concurrent.ExecutorService executorService
      • actionCount

        private final int actionCount
    • Constructor Detail

      • Blitzer

        public Blitzer​(int actionCount)
      • Blitzer

        public Blitzer​(int actionCount,
                       int threadCount)
      • Blitzer

        public Blitzer​(int actionCount,
                       int threadCount,
                       java.util.concurrent.ThreadFactory threadFactory)
      • Blitzer

        public Blitzer​(int actionCount,
                       java.util.concurrent.ExecutorService executorService)
    • Method Detail

      • totalActionCount

        public int totalActionCount()
      • blitz

        public void blitz​(java.lang.Runnable action)
                   throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • blitz

        public void blitz​(long timeoutMs,
                          java.lang.Runnable action)
                   throws java.lang.InterruptedException,
                          java.util.concurrent.TimeoutException
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • spawnThreads

        private java.util.concurrent.CountDownLatch spawnThreads​(java.lang.Runnable action)
      • shutdown

        public void shutdown()