Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class TaskExecutor
- Object
- TaskExecutor
A named place background work runs: a pool of platform threads, or virtual threads on the server’s hosts.
Configured as cn1.task.executor.<name>.threads and
cn1.task.executor.<name>.kind (platform or virtual),
and listed by Tasks.executors. The threads of a pool start on the
first task, so an executor the configuration names and nothing uses costs a
map entry.
A virtual executor hands each task to a virtual thread of its own; on a runtime or a server that has none – the Java SE arm, a TLS server, Windows – it runs the task on its pool instead, which is why it has a size too.
Methods
public String getName() | |
public synchronized boolean isVirtual() | Whether this executor’s tasks go to virtual threads: always for a virtual one, and for an AUTO one while its server has hosts to run them on. |
public int getSize() | |
public synchronized int getQueueDepth() | Tasks waiting for a thread. |
public synchronized int getActiveCount() | Tasks running now. |
public synchronized long getCompletedCount() | |
public synchronized long getFailedCount() | Tasks that ended with an exception nobody received. |
public void execute(Runnable task) | Runs task on this executor. |
public synchronized boolean isShutdown() | Whether shutdown(long) has been called; it then refuses tasks. |
public synchronized void shutdown(long waitMillis) | Stops taking tasks and waits up to waitMillis for the queued and running ones to finish. |
public synchronized long getDroppedCount() | Tasks the shutdown deadline dropped before they could start. |
public synchronized String toString() | Returns a string representation of the object. |
Inherited methods
Method details
getName
public String getName()isVirtual
public synchronized boolean isVirtual()getSize
public int getSize()getQueueDepth
public synchronized int getQueueDepth()getActiveCount
public synchronized int getActiveCount()getCompletedCount
public synchronized long getCompletedCount()getFailedCount
public synchronized long getFailedCount()execute
public void execute(Runnable task)task on this executor.Throws
IllegalStateException- once the server has stopped it
isShutdown
public synchronized boolean isShutdown()shutdown(long) has been called; it then refuses tasks.shutdown
public synchronized void shutdown(long waitMillis)Stops taking tasks and waits up to waitMillis for the queued and
running ones to finish.
Called from one of this executor’s own tasks – one that stops the server – that task is not waited for: it cannot finish until this returns. The HTTP drain leaves out the request that stopped it the same way.
getDroppedCount
public synchronized long getDroppedCount()toString
public synchronized String toString()