Index: libcfa/src/bits/random.hfa
===================================================================
--- libcfa/src/bits/random.hfa	(revision 5b7a366285c53991ffc13bb9142a7410cd0b7f56)
+++ libcfa/src/bits/random.hfa	(revision 9b33337ddda00ac15b5ea41e8d984d0e584177d0)
Index: libcfa/src/concurrency/invoke.h
===================================================================
--- libcfa/src/concurrency/invoke.h	(revision 5b7a366285c53991ffc13bb9142a7410cd0b7f56)
+++ libcfa/src/concurrency/invoke.h	(revision 9b33337ddda00ac15b5ea41e8d984d0e584177d0)
@@ -10,6 +10,6 @@
 // Created On       : Tue Jan 17 12:27:26 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Jan  6 16:37:40 2022
-// Update Count     : 47
+// Last Modified On : Sun Jan  9 19:06:45 2022
+// Update Count     : 48
 //
 
@@ -211,4 +211,6 @@
 		struct processor * last_proc;
 
+		uint32_t random_state;							// fast random numbers
+
 		#if defined( __CFA_WITH_VERIFY__ )
 			void * canary;
Index: libcfa/src/concurrency/kernel/fwd.hfa
===================================================================
--- libcfa/src/concurrency/kernel/fwd.hfa	(revision 5b7a366285c53991ffc13bb9142a7410cd0b7f56)
+++ libcfa/src/concurrency/kernel/fwd.hfa	(revision 9b33337ddda00ac15b5ea41e8d984d0e584177d0)
@@ -77,8 +77,9 @@
 
 		static inline uint64_t __tls_rand() {
+			return
 			#if defined(__SIZEOF_INT128__)
-				return __lehmer64( kernelTLS().rand_seed );
+				__lehmer64( kernelTLS().rand_seed );
 			#else
-				return __xorshift64( kernelTLS().rand_seed );
+				__xorshift64( kernelTLS().rand_seed );
 			#endif
 		}
@@ -91,5 +92,4 @@
 
 		static inline unsigned __tls_rand_fwd() {
-
 			kernelTLS().ready_rng.fwd_seed = (A * kernelTLS().ready_rng.fwd_seed + C) & (M - 1);
 			return kernelTLS().ready_rng.fwd_seed >> D;
@@ -112,6 +112,4 @@
 		}
 	}
-
-
 
 	extern void disable_interrupts();
Index: libcfa/src/concurrency/thread.cfa
===================================================================
--- libcfa/src/concurrency/thread.cfa	(revision 5b7a366285c53991ffc13bb9142a7410cd0b7f56)
+++ libcfa/src/concurrency/thread.cfa	(revision 9b33337ddda00ac15b5ea41e8d984d0e584177d0)
@@ -10,6 +10,6 @@
 // Created On       : Tue Jan 17 12:27:26 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Dec  4 09:17:49 2019
-// Update Count     : 9
+// Last Modified On : Mon Jan 10 17:05:35 2022
+// Update Count     : 28
 //
 
@@ -27,7 +27,9 @@
 uint64_t thread_rand();
 
+extern uint32_t __thread_seed;							// global thread seed
+
 //-----------------------------------------------------------------------------
 // Thread ctors and dtors
-void ?{}(thread$ & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
+void ?{}( thread$ & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
 	context{ 0p, 0p };
 	self_cor{ name, storage, storageSize };
@@ -39,4 +41,5 @@
 	self_mon.owner = &this;
 	self_mon.recursion = 1;
+	random_state = __thread_seed;
 	self_mon_p = &self_mon;
 	curr_cluster = &cl;
@@ -178,4 +181,20 @@
 }
 
+#define GENERATOR LCG
+
+inline uint32_t MarsagliaXor( uint32_t & state ) {
+	state ^= state << 6;
+	state ^= state >> 21;
+	state ^= state << 7;
+	return state;
+} // MarsagliaXor
+
+inline uint32_t LCG( uint32_t & state ) {				// linear congruential generator
+	return state = 36969 * (state & 65535) + (state >> 16); // 36969 is NOT prime!
+} // LCG
+
+void set_seed( uint32_t seed ) { active_thread()->random_state = seed; __thread_seed = seed; }
+uint32_t prng( void ) { return GENERATOR( active_thread()->random_state ); } // [0,UINT_MAX]
+
 // Local Variables: //
 // mode: c //
Index: libcfa/src/fstream.cfa
===================================================================
--- libcfa/src/fstream.cfa	(revision 5b7a366285c53991ffc13bb9142a7410cd0b7f56)
+++ libcfa/src/fstream.cfa	(revision 9b33337ddda00ac15b5ea41e8d984d0e584177d0)
@@ -10,6 +10,6 @@
 // Created On       : Wed May 27 17:56:53 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Oct 10 11:23:05 2021
-// Update Count     : 512
+// Last Modified On : Mon Jan 10 08:45:05 2022
+// Update Count     : 513
 //
 
@@ -52,5 +52,5 @@
 inline void setPrt$( ofstream & os, bool state ) { os.prt$ = state; }
 
-inline void lock( ofstream & os ) with( os ) {	lock( os.lock$ ); }
+inline void lock( ofstream & os ) with( os ) { lock( os.lock$ ); }
 inline void unlock( ofstream & os ) { unlock( os.lock$ ); }
 
Index: libcfa/src/stdlib.cfa
===================================================================
--- libcfa/src/stdlib.cfa	(revision 5b7a366285c53991ffc13bb9142a7410cd0b7f56)
+++ libcfa/src/stdlib.cfa	(revision 9b33337ddda00ac15b5ea41e8d984d0e584177d0)
@@ -10,9 +10,11 @@
 // Created On       : Thu Jan 28 17:10:29 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Jan  3 09:36:27 2022
-// Update Count     : 519
+// Last Modified On : Mon Jan 10 17:07:21 2022
+// Update Count     : 572
 //
 
 #include "stdlib.hfa"
+//#include "concurrency/kernel/fwd.hfa"
+#include "concurrency/invoke.h"							// random_state
 
 //---------------------------------------
@@ -221,15 +223,7 @@
 //---------------------------------------
 
-static uint32_t seed = 0;								// current seed
-static thread_local uint32_t state;						// random state
-
-void set_seed( uint32_t seed_ ) { state = seed = seed_; }
-uint32_t get_seed() { return seed; }
-
 #define GENERATOR LCG
 
 inline uint32_t MarsagliaXor( uint32_t & state ) {
-	if ( unlikely( seed == 0 ) ) set_seed( rdtscl() );
-	else if ( unlikely( state == 0 ) ) state = seed;
 	state ^= state << 6;
 	state ^= state >> 21;
@@ -239,12 +233,14 @@
 
 inline uint32_t LCG( uint32_t & state ) {				// linear congruential generator
-	if ( unlikely( seed == 0 ) ) set_seed( rdtscl() );
-	else if ( unlikely( state == 0 ) ) state = seed;
 	return state = 36969 * (state & 65535) + (state >> 16); // 36969 is NOT prime!
 } // LCG
 
+uint32_t __thread_seed = rdtscl();						// global thread seed
+
+void set_seed( uint32_t seed ) { __thread_seed = seed; }
+uint32_t get_seed() { return  __thread_seed; }
 uint32_t prng( PRNG & prng ) with( prng ) { callcnt += 1; return GENERATOR( state ); }
 
-uint32_t prng( void ) { return GENERATOR( state ); }
+uint32_t prng( void ) { return GENERATOR( __thread_seed ); } // [0,UINT_MAX]
 
 //---------------------------------------
Index: libcfa/src/stdlib.hfa
===================================================================
--- libcfa/src/stdlib.hfa	(revision 5b7a366285c53991ffc13bb9142a7410cd0b7f56)
+++ libcfa/src/stdlib.hfa	(revision 9b33337ddda00ac15b5ea41e8d984d0e584177d0)
@@ -10,6 +10,6 @@
 // Created On       : Thu Jan 28 17:12:35 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Jan  2 22:53:57 2022
-// Update Count     : 594
+// Last Modified On : Mon Jan 10 17:03:18 2022
+// Update Count     : 619
 //
 
@@ -21,4 +21,5 @@
 #include <stdlib.h>										// *alloc, strto*, ato*
 #include <heap.hfa>
+
 
 // Reduce includes by explicitly defining these routines.
@@ -391,5 +392,5 @@
 }; // PRNG
 
-extern uint32_t prng( PRNG & prng ) __attribute__(( warn_unused_result )); // [0,UINT_MAX]
+uint32_t prng( PRNG & prng ) __attribute__(( warn_unused_result )); // [0,UINT_MAX]
 static inline {
 	void set_seed( PRNG & prng, uint32_t seed_ ) with( prng ) { state = seed = seed_; } // set seed
@@ -402,12 +403,10 @@
 } // distribution
 
-extern void set_seed( uint32_t seed );					// set per thread seed
-extern uint32_t get_seed();								// get seed
-extern uint32_t prng( void ) __attribute__(( warn_unused_result )); // [0,UINT_MAX]
+void set_seed( uint32_t seed_ ) OPTIONAL_THREAD;
+uint32_t get_seed() __attribute__(( warn_unused_result ));
+uint32_t prng( void ) __attribute__(( warn_unused_result )) OPTIONAL_THREAD; // [0,UINT_MAX]
 static inline {
-	uint32_t prng( uint32_t u ) __attribute__(( warn_unused_result ));
-	uint32_t prng( uint32_t u ) { return prng() % u; }	// [0,u)
-	uint32_t prng( uint32_t l, uint32_t u ) __attribute__(( warn_unused_result ));
-	uint32_t prng( uint32_t l, uint32_t u ) { return prng( u - l + 1 ) + l; } // [l,u]
+	uint32_t prng( uint32_t u ) __attribute__(( warn_unused_result )) { return prng() % u; } // [0,u)
+	uint32_t prng( uint32_t l, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( u - l + 1 ) + l; } // [l,u]
 } // distribution
 
