Java Thread Callable minScalar(final double[] a, final double scalar)

Here you can find the source of minScalar(final double[] a, final double scalar)

Description

min Scalar

License

Open Source License

Declaration

public static Callable minScalar(final double[] a, final double scalar) throws Exception 

Method Source Code


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

public class Main {
    public static Callable minScalar(final double[] a, final double scalar) throws Exception {
        Callable c = new Callable() {
            public Object call() throws Exception {
                double[] result = new double[a.length];
                for (int i = 0; i < a.length; i++) {
                    result[i] = Math.min(a[i], scalar);
                }//from w  w w  .  ja  v a  2s  .co m
                return result;
            }
        };
        return c;
    }

    public static Callable min(final double[] a, final double[] b) throws Exception {
        if (a.length != b.length)
            throw new Exception("");
        Callable c = new Callable() {
            public Object call() throws Exception {
                double[] result = new double[a.length];
                for (int i = 0; i < a.length; i++) {
                    result[i] = Math.min(a[i], b[i]);
                }
                return result;
            }
        };
        return c;
    }
}

Related

  1. getFuture(ExecutorService executorService, Callable callable)
  2. getRandomValueForPrimitive(Class type)
  3. invokeAll(Collection> tasks, ExecutorService executorService)
  4. invokeBulkActions(Collection> tasks)
  5. max(final double[] a, final double[] b)
  6. powerTo(final double base, final double[] exponents)
  7. repeatedlyTry(Callable task, int maxRounds, long backoff)
  8. resolveCompositeKey(final String key, final Map props)
  9. resolveSingle(Object object)