Skip to content

Commit

Permalink
further tweak of threadpool usage
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Apr 20, 2020
1 parent c1db833 commit 22cfb08
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.security.SecureRandom;
import java.security.SecureRandomSpi;
import java.security.Security;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -47,7 +47,6 @@
public class DRBG
{
private static final String PREFIX = DRBG.class.getName();
private static final Executor rngThread = Executors.newFixedThreadPool(1);

// {"Provider class name","SecureRandomSpi class name"}
private static final String[][] initialEntropySourceNames = new String[][]
Expand Down Expand Up @@ -371,6 +370,8 @@ public Integer run()
private static class HybridSecureRandom
extends SecureRandom
{
private final ExecutorService rngThread = Executors.newFixedThreadPool(1);

private final AtomicBoolean seedAvailable = new AtomicBoolean(false);
private final AtomicInteger samples = new AtomicInteger(0);
private final SecureRandom baseRandom = createInitialEntropySource();
Expand Down Expand Up @@ -426,6 +427,11 @@ public byte[] generateSeed(int numBytes)
return data;
}

public void finalize()
{
rngThread.shutdown();
}

private class SignallingEntropySource
implements EntropySource
{
Expand Down

0 comments on commit 22cfb08

Please sign in to comment.