Code example for Random

Methods: nextBoolean

0
        final boolean writer;
 
        ReaderWriter(FileChannel fc, boolean interruptible) {
            this.fc = fc;
            this.interruptible = interruptible;
            this.writer = rand.nextBoolean();
        } 
 
        public void run() { 
            ByteBuffer bb = ByteBuffer.allocate(K);
            if (writer)
                rand.nextBytes(bb.array());
 
            try { 
                for (;;) { 
                    long position = rand.nextInt(K*K - bb.capacity());
                    if (writer) {
                        bb.position(0).limit(bb.capacity());
                        fc.write(bb, position);
                    } else {