Examples of nextProbablePrime()


Examples of java.math.BigInteger.nextProbablePrime()

    private volatile boolean cancelled;

    public void run() {
        BigInteger p = BigInteger.ONE;
        while (!cancelled) {
            p = p.nextProbablePrime();
            synchronized (this) {
                primes.add(p);
            }
        }
    }
View Full Code Here

Examples of java.math.BigInteger.nextProbablePrime()

    public void run() {
        try {
            BigInteger p = BigInteger.ONE;
            while (!Thread.currentThread().isInterrupted())
                queue.put(p = p.nextProbablePrime());
        } catch (InterruptedException consumed) {
            /* Allow thread to exit */
        }
    }

View Full Code Here

Examples of java.math.BigInteger.nextProbablePrime()

    public void run() {
        try {
            BigInteger p = BigInteger.ONE;
            while (!cancelled)
                queue.put(p = p.nextProbablePrime());
        } catch (InterruptedException consumed) {
        }
    }

    public void cancel() {
View Full Code Here

Examples of java.math.BigInteger.nextProbablePrime()

    private int getPrime(int n) {
        int prev = 0;
        BigInteger b = BigInteger.valueOf(n);
        int prime = 0;
        int max = n + n / 2;
        while ((prime = b.nextProbablePrime().intValue()) < max) {
            prev = prime;
            b = BigInteger.valueOf(prime);
        }
        return prev;
    }
View Full Code Here

Examples of java.math.BigInteger.nextProbablePrime()

        BigInteger p1, p2, p3;
        p1 = p2 = p3 = ZERO;

        // First test nextProbablePrime on the low range starting at zero
        for (int i=0; i<primesTo100.length; i++) {
            p1 = p1.nextProbablePrime();
            if (p1.longValue() != primesTo100[i]) {
                System.err.println("low range primes failed");
                System.err.println("p1 is "+p1);
                System.err.println("expected "+primesTo100[i]);
                failCount++;
View Full Code Here

Examples of java.math.BigInteger.nextProbablePrime()

        }

        // Test nextProbablePrime on a relatively small, known prime sequence
        p1 = BigInteger.valueOf(aPrimeSequence[0]);
        for (int i=1; i<aPrimeSequence.length; i++) {
            p1 = p1.nextProbablePrime();
            if (p1.longValue() != aPrimeSequence[i]) {
                System.err.println("prime sequence failed");
                failCount++;
            }
        }
View Full Code Here

Examples of java.math.BigInteger.nextProbablePrime()

        // Next, pick some large primes, use nextProbablePrime to find the
        // next one, and make sure there are no primes in between
        for (int i=0; i<100; i+=10) {
            p1 = BigInteger.probablePrime(50 + i, rnd);
            p2 = p1.add(ONE);
            p3 = p1.nextProbablePrime();
            while(p2.compareTo(p3) < 0) {
                if (p2.isProbablePrime(100)){
                    System.err.println("nextProbablePrime failed");
                    System.err.println("along range "+p1.toString(16));
                    System.err.println("to "+p3.toString(16));
View Full Code Here

Examples of java.math.BigInteger.nextProbablePrime()

          // configuration of cleaners and workers.
          int cpus = Runtime.getRuntime().availableProcessors();
          int cleaners = Math.max(24, cpus * 2);
          int workers = Math.max(24, cpus * 2);
          BigInteger tmp = BigInteger.valueOf((cleaners + workers) * 2);
          value = tmp.nextProbablePrime();

          Message message =
              INFO_ERGONOMIC_SIZING_OF_JE_LOCK_TABLES.get(String
                  .valueOf(cfg.dn().getRDN().getAttributeValue(0)),
                  (Number) value);
View Full Code Here

Examples of java.math.BigInteger.nextProbablePrime()

    public void run() {
        try {
            BigInteger p = BigInteger.ONE;
            while (!cancelled)    //never checked because put blocked (queue full and waiting for take method)
                queue.put(p = p.nextProbablePrime());
        } catch (InterruptedException consumed) {
        }
    }

    public void cancel() {
View Full Code Here

Examples of java.math.BigInteger.nextProbablePrime()

        try {
            BigInteger p = BigInteger.ONE;
            //while(true)//could be
            while (!Thread.currentThread().isInterrupted())  //not really necessary
                //check  putLock.lockInterruptibly(); in method put inside
                queue.put(p = p.nextProbablePrime());
        } catch (InterruptedException consumed) {
        }
    }

    public void cancel() {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.