THREADED statement

Purpose

Declare thread-local variables.

Syntax

THREADED variable[()] [AS type] [, variable[()]]

THREADED variable[()] [, variable[()]] [, ...] AS type

Remarks

Threaded variables are global to every Sub, Function, Method, and Property but are not shared across threads.  Each thread has its own independent set of thread-local variables.

To declare an array as a threaded variable, use an empty set of parentheses in the variable list: You can then use the DIM statement to dimension the array.

THREADED MyArray%()

THREADED StringArray() AS STRING

The THREADED statement may, optionally, accept a list of variables, all of which are defined by the type descriptor keyword that follows them.  For example:

THREADED aaa, bbb, ccc AS INTEGER

THREADED vptr, aptr() AS LONG PTR

Restrictions

DEFtype has no effect on variables defined by a THREADED statement.

See also

DIM, GLOBAL, INSTANCE, LOCAL, STATIC

Example

THREADED xxx, yyy, zzz AS INTEGER

THREADED vptr, aptr() AS LONG PTR