Class Tasks
Where background work runs: the named TaskExecutors, and two
shorthands for running something once.
Tasks.platform(new Runnable() { public void run() { rebuildIndex(); } });
Tasks.virtual(new Runnable() { public void run() { pingWebhooks(); } });
Whose executors
Every server has its own executors, sized from its own configuration and
stopped with it: two servers in one process -- or one stopped and started
again -- must not share a pool, or stopping one would shut down the executor
the other's scheduler and @Async methods still submit to. The calls
here are static because generated code makes them, so they find the server by
the calling thread: a request thread, a task thread and a scheduled job all
carry the server they work for, and so does the thread that builds and starts
the beans. A thread that carries none -- one the program started itself --
gets the most recently started server that is still running.
Which thread
A virtual thread is the cheaper one, and the right one for work that waits
on sockets -- a PostgreSQL or MySQL query or an HTTP call parks it. It is the
wrong one for SQLite or file work: those block the HOST thread under the
virtual thread, and every other virtual thread on that host with it. See
com.codename1.backend.annotations.ThreadKind.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ListThe executors of every running server, for a listing.static voidRunstaskonce on the default pool of platform threads.static voidRunstaskonce on a virtual thread, or a platform one where there are none.
-
Method Details
-
virtual
Runstaskonce on a virtual thread, or a platform one where there are none. -
platform
Runstaskonce on the default pool of platform threads. -
executors
The executors of every running server, for a listing.
-