Back Previous Next


Linguist basic package - fork

Syntax:

   fork to {label}

Keyword handler:

   linguist.basic.keyword.BKFork.class

Runtime handler(s):

   linguist.basic.handler.BHFork.class

Function:

Create a new program thread and start executing it at the label specified. The current thread will resume once the new thread relinquishes control, e.g. with a stop instruction.

The concurrent execution implied by the fork instruction is not handled using Java threads, but instead by co-operative multitasking within the same thread. This is a more convenient mechanism where all the concurrent tasks share the same variables. You can alternatively run multiple scripts, which does make use of Java threads and is more suitable where the different tasks are less tightly involved with each other. Mechanisms then exist for sending messages from one script to another, whereas forked threads all share the same variable space.

See also go and gosub.

Example(s):

   fork to AnimateCharacter


Back Previous Next