Package org.sosy_lab.common
Class Concurrency
java.lang.Object
org.sosy_lab.common.Concurrency
Helper methods for concurrency related things.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExecutorServiceCreates a thread pool of fixed size.static ExecutorServicecreateThreadPool(ThreadFactory threadFactory) Creates a thread pool of fixed size.static ThreadnewDaemonThread(String name, Runnable r) Create a new daemon thread with a name.static ThreadCreate a new non-daemon thread with a name.static voidwaitForTermination(ExecutorService executor) Wait uninterruptibly until an ExecutorService has shutdown.
-
Method Details
-
waitForTermination
Wait uninterruptibly until an ExecutorService has shutdown. It also ensures full memory visibility of everything that was done in the callables.Interrupting the thread will have no effect, but this method will set the thread's interrupted flag in this case.
-
createThreadPool
Creates a thread pool of fixed size. Size is determined by processors available to the JVM.- Returns:
- thread pool
-
createThreadPool
Creates a thread pool of fixed size. Size is determined by processors available to the JVM.- Parameters:
threadFactory- The thread factory to be used.- Returns:
- thread pool
-
newThread
Create a new non-daemon thread with a name. Compared to creating threads manually, this has the advantage that the thread will be created with the default settings. By default, Java lets threads inherit some settings from the creating thread.- Parameters:
name- The name of the new thread.r- TheRunnableto execute in the new thread.- Returns:
- A new thread, not yet started.
-
newDaemonThread
Create a new daemon thread with a name. Compared to creating threads manually, this has the advantage that the thread will be created with the default settings. By default, Java lets threads inherit some settings from the creating thread.- Parameters:
name- The name of the new thread.r- TheRunnableto execute in the new thread.- Returns:
- A new daemon thread, not yet started.
-