Java Utililty Methods Thread Callable

List of utility methods to do Thread Callable

Description

The list of methods to do Thread Callable are organized into topic(s).

Method

Tcall(Callable callable)
call
try {
    return callable.call();
} catch (Exception e) {
    throw new RuntimeException(e);
Tcall(final Callable c)
call
try {
    return c == null ? null : c.call();
} catch (final Exception e) {
    throw toRuntimeException(e);
Callable>callableListCreator()
callable List Creator
return new Callable<List<T>>() {
    @Override
    public List<T> call() {
        return new ArrayList<T>();
};
booleancallConditionAndReturnResult(Callable condition)
call Condition And Return Result
try {
    return condition.call();
} catch (Exception exception) {
    throw new RuntimeException(exception);
ObjectcallInLoader(Callable body, ClassLoader loader)
call In Loader
ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
try {
    Thread.currentThread().setContextClassLoader(loader);
    return body.call();
} finally {
    Thread.currentThread().setContextClassLoader(originalCl);
TcallInLocale(Locale locale, Callable task)
call In Locale
Locale realLocale = Locale.getDefault();
try {
    Locale.setDefault(locale);
    return task.call();
} finally {
    Locale.setDefault(realLocale);
TcallWithSystemProperty(String name, String value, Callable callee)
call With System Property
String oldValue = System.getProperty(name);
try {
    System.setProperty(name, value);
    return callee.call();
} finally {
    System.setProperty(name, oldValue);
CallablecopyFromList(final List list, final double[][] data, final int cols)
copy From List
Callable c = new Callable() {
    public Object call() throws Exception {
        int s = list.size();
        double[] rowData = null;
        int row = -1;
        int col = 0;
        for (int i = 0; i < s; i++) {
            if (i % cols == 0) {
...
CallablecopyInto(final List list, final double[] data)
copy Into
Callable c = new Callable() {
    public Object call() throws Exception {
        for (int i = 0; i < data.length; i++) {
            list.add(data[i]);
        return list;
};
...
voidexecuteLocally(Callable task)
execute Locally
try {
    task.call();
} catch (RuntimeException ex) {
    throw ex;
} catch (Exception ex) {
    throw new RuntimeException(ex);