2 summary::represents an individual operating system thread
3 categories::Core>Kernel
4 related:: Classes/Routine
8 Normally there is no need to instantiate a Thread, but its subclass Routine is very useful.
10 It is wise not to fiddle with the source code for this class; see the warnings in the class file.
13 The global pseudo-variable code::thisThread:: always returns the enclosing thread running the given code. A Thread is aware of its own attached clock and associated beats and seconds timing, and has an individual random number seed and exception handler.
21 discussion:: You will not typically do this yourself but as a result of creating Routines, for example.
24 g = Thread({"hello".postln;});
25 g.seconds; //time of creation, cannot advance without a clock
29 A function with code for the thread to run.
32 defaults to 64 depth call stack.
37 Get or set the elapsed beats (logical time) of the thread
40 Get or set the elapsed seconds (logical time) of the thread.
43 Get or set the thread's clock
46 Returns:: true if it is playing
57 The internal state values for a Thread instance can be polled:
64 subsection::Seeding the random number generator
66 see also: link::Reference/randomSeed::
69 Set the random number generator seed using a single integer
73 g = thisThread.randSeed = 4;
74 10.do{1.0.rand2.postln};
79 Get or set the three integer array which defines the internal basis for the random number generator. You can use this to get back the exact same random number sequence, and it provides a mechanism for automatic replay for generative music.
83 g = thisThread.randData;
84 10.do{1.0.rand2.postln};
87 // each time the seed is reset, the random number generation should give the same sequence
88 thisThread.randData_(Int32Array[ -662787342, 1546785953, 1661466823 ]);
89 10.do{1.0.rand2.postln};