Corso di Raku / Programmazione funzionale, concorrente, reattiva e web / Programmazione concorrente / Thread / Exercises / Eseguite in un thread

Soluzione: Eseguite in un thread

Ecco una possibile soluzione del compito.

Codice

my $t = Thread.start({ say 'working' });
$t.finish;

🦋 Trova il programma nel file run-in-thread.raku.

Output

working

Commenti

  1. Thread.start esegue il blocco su un nuovo thread.

  2. .finish aspetta che il thread finisca, così il programma non termina prima che working sia stampato.

← Eseguite in un thread   |   Unite e attendete →