Class TaskExecutor
- java.lang.Object
-
- uk.co.caprica.vlcj.support.eventmanager.TaskExecutor
-
public final class TaskExecutor extends Object
Singleton component used to execute tasks on a thread different to the native event handler background thread.Native events are generated on a native event callback thread. It is not allowed to call back into LibVLC from this thread, if you do either the call will be ineffective, strange behaviour will happen, or a fatal JVM crash may occur.
To mitigate this, tasks can be submitted, serialised and executed using this service.
Internally a single-threaded executor service is used to execute tasks that need to be off-loaded from a native callback thread.
See
submit(Runnable)
.
-
-
Constructor Summary
Constructors Constructor Description TaskExecutor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
release()
Release this component.void
release(long timeout)
Release this component.void
submit(Runnable r)
Submit a task for asynchronous execution.
-
-
-
Method Detail
-
submit
public void submit(Runnable r)
Submit a task for asynchronous execution.- Parameters:
r
- task to submit
-
release
public void release()
Release this component.An attempt is made to perform an orderly shutdown, so any tasks in the queue are given a chance to complete cleanly within the default timeout period.
Consequently there may be a short delay before this method returns.
If there are no tasks waiting, this method will return immediately.
-
release
public void release(long timeout)
Release this component.An attempt is made to perform an orderly shutdown, so any tasks in the queue are given a chance to complete cleanly within the specified timeout period.
Consequently there may be a short delay before this method returns.
If there are no tasks waiting, this method will return immediately.
- Parameters:
timeout
- timeout, milliseconds
-
-