Java Utililty Methods Thread Callable

List of utility methods to do Thread Callable

  1. HOME
  2. Java
  3. T
  4. Thread Callable

Description

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

Method

T call(Callable callable)
call
try {
 return callable.call();
} catch (Exception e) {
 throw new RuntimeException(e);
T call(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>();
};
boolean callConditionAndReturnResult(Callable condition)
call Condition And Return Result
try {
 return condition.call();
} catch (Exception exception) {
 throw new RuntimeException(exception);
Object callInLoader(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);
T callInLocale(Locale locale, Callable task)
call In Locale
Locale realLocale = Locale.getDefault();
try {
 Locale.setDefault(locale);
 return task.call();
} finally {
 Locale.setDefault(realLocale);
T callWithSystemProperty(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);
Callable copyFromList(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) {
...
Callable copyInto(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;
};
...
void executeLocally(Callable task)
execute Locally
try {
 task.call();
} catch (RuntimeException ex) {
 throw ex;
} catch (Exception ex) {
 throw new RuntimeException(ex);


AltStyle によって変換されたページ (->オリジナル) /