On this page:
Thread
thread
Thread.wait
Thread.break
Thread.Break
Thread.Break.interrupt
Thread.Break.hang_  up
Thread.Break.terminate
Thread.kill
Thread.handle
Thread.from_  handle
Thread.sleep
8.16.0.2

15.1 Threads🔗ℹ

A thread is a concurrent thread of evaluation. Rhombus schedules threads preemptively, but conceptually on the same physical processor; that is, threads provide concurrency, but not parallelism. Threads can communicate via shared state, and they can synchronize using semaphores or other synchronizable events.

A Thread object is itself a synchornizable event that is ready for synchronization when the thread has terminated. The synchronization result is just the thread object itself.

class

class Thread():

  constructor (thunk :: Function.of_arity(0))

 

expression

thread:

  body

  ...

The Thread class represents a thread. The Thread constructor accepts a function to call in a newly created thread. A thread: body; ... form is equivalent to Thread(fun (): body; ...).

A Thread object satisfies Evt and includes the Evt.sync method.

method

method (th :: Thread).wait() :: Void

Blocks until the thread th terminates.

method

method (th :: Thread).break(kind :: Thread.Break = #'interrupt) :: Void

 

enumeration

enum Thread.Break:

  interrupt

  hang_up

  terminate

Asynchronously raises an Exn.Break exception in th, assuming that it has not yet terminated. If kind is #'hang_up or #'terminate, then the exception is more specifically Exn.Break.HangUp or Exn.Break.Terminate, respectively.

method

method (th :: Thread).kill() :: Void

Terminates the thread th. If the thread has already terminated, then Thread.kill has no effect.

property

property (th :: Thread).handle

 

function

fun Thread.from_handle(handle) :: Thread

The Thread.handle property accesses a thread object’s underlying Racket representation. The Thread.from_handle function constructs a Rhombus thread object from a Racket thread object.

function

fun Thread.sleep(secs :: NonnegReal) :: Void

Causes the current thread to pause for at least secs seconds.