Java Thread Callable shuffleRow(final double[] data)

Here you can find the source of shuffleRow(final double[] data)

Description

shuffle Row

License

Open Source License

Declaration

public static Callable shuffleRow(final double[] data) 

Method Source Code


//package com.java2s;
import java.util.concurrent.*;

import java.util.Random;

public class Main {
    static Random random = new Random();

    public static Callable shuffleRow(final double[] data) {
        return new Callable() {
            int len = data.length;

            public Object call() throws Exception {
                for (int i = 0; i < data.length; i++) {
                    double temp = data[i];
                    int index = random.nextInt(len);
                    data[i] = data[index];
                    data[index] = temp;/*from w w w  .j  ava2 s . c  om*/
                }
                return data;
            }
        };
    }
}

Related

  1. runConcurrently(final Callable task)
  2. runConcurrently(final Callable task, final int times)
  3. runInBackground(final Callable callable)
  4. runTest(Callable test)
  5. runWithTimeout(long millisTimeout, Callable callable)
  6. submitAndWait(ListeningExecutorService service, Callable ca)
  7. submitManyAndWait(ListeningExecutorService service, Iterable> cas, FutureCallback fca)
  8. sum(final double[] a)
  9. sumOfSquares(final double[] data)