pl.edu.icm.jlargearrays
Class ConcurrencyUtils
- java.lang.Object
-
- pl.edu.icm.jlargearrays.ConcurrencyUtils
-
public class ConcurrencyUtils extends java.lang.ObjectConcurrency utilities.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static longgetConcurrentThreshold()Returns the minimum length of array for which multiple threads are used.static intgetNumberOfProcessors()Returns the number of available processors.static intgetNumberOfThreads()Returns the current number of threads.static java.util.concurrent.ExecutorServicegetThreadPool()Returns the pool of threads.static voidsetConcurrentThreshold(long concurrentThreshold)Sets the minimum length of an array for which multiple threads are used.static voidsetNumberOfThreads(int n)Sets the number of threads.static voidsetThreadPool(java.util.concurrent.ExecutorService threadPool)Sets the pool of threads.static voidshutdownThreadPoolAndAwaitTermination()Shutdowns all submitted tasks.static <T> java.util.concurrent.Future<T>submit(java.util.concurrent.Callable<T> task)Submits a value-returning task for execution and returns a Future representing the pending results of the task.static java.util.concurrent.Future<?>submit(java.lang.Runnable task)Submits a Runnable task for execution and returns a Future representing that task.static voidwaitForCompletion(java.util.concurrent.Future<?>[] futures)Waits for all threads to complete computation.
-
-
-
Method Detail
-
getConcurrentThreshold
public static long getConcurrentThreshold()
Returns the minimum length of array for which multiple threads are used.- Returns:
- the minimum length of array for which multiple threads are used
-
setConcurrentThreshold
public static void setConcurrentThreshold(long concurrentThreshold)
Sets the minimum length of an array for which multiple threads are used.- Parameters:
concurrentThreshold- minimum length of an array for which multiple threads are used
-
getNumberOfProcessors
public static int getNumberOfProcessors()
Returns the number of available processors.- Returns:
- number of available processors
-
getNumberOfThreads
public static int getNumberOfThreads()
Returns the current number of threads.- Returns:
- the current number of threads.
-
setNumberOfThreads
public static void setNumberOfThreads(int n)
Sets the number of threads.- Parameters:
n- new value of threads
-
submit
public static <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
Submits a value-returning task for execution and returns a Future representing the pending results of the task.- Type Parameters:
T- type- Parameters:
task- task for execution- Returns:
- handle to the task submitted for execution
-
submit
public static java.util.concurrent.Future<?> submit(java.lang.Runnable task)
Submits a Runnable task for execution and returns a Future representing that task.- Parameters:
task- task for execution- Returns:
- handle to the task submitted for execution
-
waitForCompletion
public static void waitForCompletion(java.util.concurrent.Future<?>[] futures) throws java.lang.InterruptedException, java.util.concurrent.ExecutionExceptionWaits for all threads to complete computation.- Parameters:
futures- list of handles to the tasks- Throws:
java.util.concurrent.ExecutionException- if the computation threw an exceptionjava.lang.InterruptedException- if the current thread was interrupted while waiting
-
setThreadPool
public static void setThreadPool(java.util.concurrent.ExecutorService threadPool)
Sets the pool of threads.- Parameters:
threadPool- pool of threads
-
getThreadPool
public static java.util.concurrent.ExecutorService getThreadPool()
Returns the pool of threads.- Returns:
- pool of threads
-
shutdownThreadPoolAndAwaitTermination
public static void shutdownThreadPoolAndAwaitTermination()
Shutdowns all submitted tasks.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG