Executors

tinyscalautils.threads.Executors
See theExecutors companion object
class Executors

A factory for customized thread pools.

It makes it easier to specify a rejected execution handler (including DiscardPolicy) and/or a thread factory (including defaultThreadFactory). Furthermore, cached thread pools are created with a keepalive time of 1 second instead of 1 minute, which is useful in tests and demos that cannot conveniently shut down a thread pool. Finally, thread pools are returned as instances of ExecutionContextExecutorService, which makes them suitable for use with Java or Scala constructs.

Instances of this class are immutable. They are created through the companion object, e.g.:

val p1 = Executors.silent.newUnlimitedThreadPool()
val p2 = Executors.silent.withFactory(tf).newThreadPool(4)

Attributes

Since

1.0

Companion
object
Source
Executors.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Executors

Members list

Value members

Concrete methods

Creates a new execution context as a fixed thread pool.

Creates a new execution context as a fixed thread pool.

Uses the rejected execution handler and thread factory of the current instance.

Value parameters

keepAlive

the duration pool threads are kept alive when idle, in seconds; 0 means indefinitely.

size

the number of threads in the pool; must be positive.

Attributes

Throws
IllegalArgumentException

if the specified size is not positive or the keep alive time is negative.

Since

1.0

Source
Executors.scala

Creates a new execution context with timer facilities, as a fixed thread pool.

Creates a new execution context with timer facilities, as a fixed thread pool.

Uses the rejected execution handler and thread factory of the current instance.

Value parameters

size

the number of threads in the pool; must be positive.

Attributes

Throws
IllegalArgumentException

if the specified size is not positive.

Since

1.0

Source
Executors.scala

Creates a new execution context as an unlimited thread pool.

Creates a new execution context as an unlimited thread pool.

Uses the rejected execution handler and thread factory of the current instance.

Value parameters

keepAlive

the duration pool threads are kept alive when idle, in seconds; 0 means indefinitely.

Attributes

Throws
IllegalArgumentException

if the keep alive time is negative.

Since

1.0

Source
Executors.scala

Returns a thread pool factory that uses a DiscardPolicy rejected execution handler, and the same thread factory as before.

Returns a thread pool factory that uses a DiscardPolicy rejected execution handler, and the same thread factory as before.

Attributes

See also
Since

1.0

Source
Executors.scala

Returns a thread pool factory that sets its threads in daemon mode and uses the same rejected execution handler as before.

Returns a thread pool factory that sets its threads in daemon mode and uses the same rejected execution handler as before.

Attributes

Since

1.0

Source
Executors.scala

Returns a thread pool factory that uses the given thread factory, and the same rejected execution handler as before..

Returns a thread pool factory that uses the given thread factory, and the same rejected execution handler as before..

Attributes

Since

1.0

Source
Executors.scala

Returns a thread pool factory that uses the given rejected execution handler, and the same thread factory as before.

Returns a thread pool factory that uses the given rejected execution handler, and the same thread factory as before.

Attributes

Since

1.0

Source
Executors.scala