src/main/java/at/favre/tools/dice/rnd/entropy/JDKThreadedEntropySource.java
public final void run() {
            try {
                while (true) {
                    // Queue full? Wait till there's room.
                    synchronized (this) {
                        while (count >= pool.length)
                            wait();
                    }

                    int counter, quanta;
                    byte v = 0;

                    // Spin count must not be under 6400
                    for (counter = quanta = 0; (counter < 6400) && (quanta < 6);
                         quanta++) {

                        // Start some noisy threads
                        try {
                            BogusThread bt = new BogusThread();
                            Thread t = new Thread(seedGroup, bt, "Dice SeedGenerator Thread");
                            t.start();
                        } catch (Exception e) {
                            throw new InternalError("internal error: " +
                                    "SeedGenerator thread creation error.");
                        }

                        // We wait 250milli quanta, so the minimum wait time
                        // cannot be under 250milli.
                        int latch = 0;
                        long l = System.currentTimeMillis() + 50;
                        while (System.currentTimeMillis() < l) {
                            synchronized (this) {
                            }
                            latch++;
                        }

                        // Translate the value using the permutation, and xor
                        // it with previous values gathered.
                        v ^= rndTab[latch % 255];
                        counter += latch;
                    }

                    // Push it into the queue and notify anybody who might
                    // be waiting for it.
                    synchronized (this) {
                        pool[end] = v;
                        end++;
                        count++;
                        if (end >= pool.length)
                            end = 0;
                        notifyAll();
                    }
                }
            } catch (Exception e) {
                throw new InternalError("internal error: " +
                        "SeedGenerator thread generated an exception.");
            }
        }
/**
         * This method does the actual work. It collects random bytes and
         * pushes them into the queue.
         */
This method does the actual work. It collects random bytes and
pushes them into the queue.
This method does the actual work . It collects random bytes and pushes them into the queue .
public final void run() {
            try {
                while (true) {
                    synchronized (this) {
                        while (count >= pool.length)
                            wait();
                    }
                    int counter, quanta;
                    byte v = 0;
                    for (counter = quanta = 0; (counter < 6400) && (quanta < 6);
                         quanta++) {
                        try {
                            BogusThread bt = new BogusThread();
                            Thread t = new Thread(seedGroup, bt, "Dice SeedGenerator Thread");
                            t.start();
                        } catch (Exception e) {
                            throw new InternalError("internal error: " +
                                    "SeedGenerator thread creation error.");
                        }
                        int latch = 0;
                        long l = System.currentTimeMillis() + 50;
                        while (System.currentTimeMillis() < l) {
                            synchronized (this) {
                            }
                            latch++;
                        }
                        v ^= rndTab[latch % 255];
                        counter += latch;
                    }
                    synchronized (this) {
                        pool[end] = v;
                        end++;
                        count++;
                        if (end >= pool.length)
                            end = 0;
                        notifyAll();
                    }
                }
            } catch (Exception e) {
                throw new InternalError("internal error: " +
                        "SeedGenerator thread generated an exception.");
            }
        }
public final void run ( ) { try { while ( true ) { synchronized ( this ) { while ( count >= pool . length ) wait ( ) ; } int counter , quanta ; byte v = 0 ; for ( counter = quanta = 0 ; ( counter < 6400 ) && ( quanta < 6 ) ; quanta ++ ) { try { BogusThread bt = new BogusThread ( ) ; Thread t = new Thread ( seedGroup , bt , "Dice SeedGenerator Thread" ) ; t . start ( ) ; } catch ( Exception e ) { throw new InternalError ( "internal error: " + "SeedGenerator thread creation error." ) ; } int latch = 0 ; long l = System . currentTimeMillis ( ) + 50 ; while ( System . currentTimeMillis ( ) < l ) { synchronized ( this ) { } latch ++ ; } v ^= rndTab [ latch % 255 ] ; counter += latch ; } synchronized ( this ) { pool [ end ] = v ; end ++ ; count ++ ; if ( end >= pool . length ) end = 0 ; notifyAll ( ) ; } } } catch ( Exception e ) { throw new InternalError ( "internal error: " + "SeedGenerator thread generated an exception." ) ; } }
This method does the actual work.
This method does the actual work .
// Queue full? Wait till there's room. // Spin count must not be under 6400 // Start some noisy threads // We wait 250milli quanta, so the minimum wait time // cannot be under 250milli. // Translate the value using the permutation, and xor // it with previous values gathered. // Push it into the queue and notify anybody who might // be waiting for it.