public void testEncryptionDecryption(
      DeterministicAead cipher,
      int numberOfThreads,
      int maxPlaintextSize,
      int numberOfEncryptionsPerThread)
      throws Exception {
    ExceptionHandler exceptionHandler = new ExceptionHandler();
    Thread[] thread = new Thread[numberOfThreads];
    for (int i = 0; i < numberOfThreads; i++) {
      thread[i] = new CryptingThread(cipher, maxPlaintextSize, numberOfEncryptionsPerThread);
      thread[i].setUncaughtExceptionHandler(exceptionHandler);
    }
    for (int i = 0; i < numberOfThreads; i++) {
      thread[i].start();
    }
    for (int i = 0; i < numberOfThreads; i++) {
      thread[i].join();
    }
    exceptionHandler.check();
  }
Encrypt and decrypt concurrently with one DeterministicAead cipher.
java_src/src/test/java/com/google/crypto/tink/subtle/DaeadThreadSafetyTest.java