Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class Tasks

  1. Object
  2. 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.

Methods

public static void virtual(Runnable task)Runs task once on a virtual thread, or a platform one where there are none.
public static void platform(Runnable task)Runs task once on the default pool of platform threads.
public static List executors()The executors of every running server, for a listing.

Inherited methods

Method details

virtual

public static void virtual(Runnable task)
Runs task once on a virtual thread, or a platform one where there are none.

platform

public static void platform(Runnable task)
Runs task once on the default pool of platform threads.

executors

public static List executors()
The executors of every running server, for a listing.