These examples cover the two fundamental PerlOnJava ithread models:
isolated_create_join.plcreates an ithread from a runtime snapshot, returns a child-owned result throughjoin, and proves that an ordinary captured scalar remains isolated in the parent.shared_lock_condition.plmarks a scalar with:shared, protects it with lexicallock, and coordinates parent and child withcond_waitandcond_signal. The condition is always checked in a loop so an early signal or spurious wakeup cannot violate the state transition.dynamic_map_reduce.pluses a tiny shared work index to distribute documents, keeps each worker's word-count hash local, and merges ordinary result graphs afterjoin. It demonstrates the recommended pattern: share coordination, not bulk mutable data.dbi_parallel_queries.plcreates a small SQLite database, lets three ithreads open and own independent DBI connections, and returns ordinary aggregate data throughjoin. Native DBI handles are never inherited or returned across runtime boundaries.
Run either example from the repository root:
./jperl examples/threads/isolated_create_join.pl
./jperl examples/threads/shared_lock_condition.pl
./jperl examples/threads/dynamic_map_reduce.pl
./jperl examples/threads/dbi_parallel_queries.plThe same source runs on standard threaded Perl:
perl examples/threads/isolated_create_join.pl
perl examples/threads/shared_lock_condition.pl
perl examples/threads/dynamic_map_reduce.pl
perl examples/threads/dbi_parallel_queries.plPerlOnJava uses Java 24 virtual threads by default. Platform threads remain a process-wide compatibility mode; selecting them does not change Perl snapshot or shared-storage semantics:
JPERL_THREAD_MODE=platform \
./jperl examples/threads/isolated_create_join.plLive attached children support targeted thread signals. A nonzero stack-size request automatically selects a platform-backed child because virtual-thread stacks are JVM-managed. Shared blessed aggregates use runtime-local proxy views over common backing; the advanced edge cases and tie-order rules are documented in the Perl threads reference. A captured PSGI runtime is not made concurrently callable merely by enabling ithreads; use the opt-in PSGI runtime pool for concurrent request execution.