Use pthread_once for rnd initialization
diff --git a/mangle.c b/mangle.c
index a1c04d2..9f1bf62 100644
--- a/mangle.c
+++ b/mangle.c
@@ -422,7 +422,7 @@
         mangle_InsertRnd,
     };
 	/* *INDENT-ON* */
-    
+
     /* Minimal number of changes is 1 */
     uint64_t changesCnt = fuzzer->dynamicFileSz * fuzzer->flipRate;
     if (changesCnt == 0ULL) {
diff --git a/util.c b/util.c
index bb13c03..ce5c598 100644
--- a/util.c
+++ b/util.c
@@ -27,6 +27,7 @@
 #include <fcntl.h>
 #include <inttypes.h>
 #include <math.h>
+#include <pthread.h>
 #include <stdarg.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -90,7 +91,7 @@
 
 static int util_urandomFd = -1;
 static __thread uint64_t rndX;
-static __thread uint64_t rndIni = false;
+pthread_once_t rndOnce = PTHREAD_ONCE_INIT;
 
 /* MMIX LCG PRNG */
 static const uint64_t a = 6364136223846793005ULL;
@@ -104,17 +105,14 @@
         }
     }
 
-    if (rndIni == false) {
-        if (files_readFromFd(util_urandomFd, (uint8_t *) & rndX, sizeof(rndX)) != sizeof(rndX)) {
-            PLOG_F("Couldn't read '%zu' bytes from /dev/urandom", sizeof(rndX));
-        }
-        rndIni = true;
+    if (files_readFromFd(util_urandomFd, (uint8_t *) & rndX, sizeof(rndX)) != sizeof(rndX)) {
+        PLOG_F("Couldn't read '%zu' bytes from /dev/urandom", sizeof(rndX));
     }
 }
 
 uint64_t util_rnd64(void)
 {
-    util_rndInit();
+    pthread_once(&rndOnce, util_rndInit);
     rndX = a * rndX + c;
     return rndX;
 }
@@ -133,7 +131,7 @@
     if (sz == 0) {
         return;
     }
-    util_rndInit();
+    pthread_once(&rndOnce, util_rndInit);
     for (size_t i = 0; i < sz; i++) {
         rndX = a * rndX + c;
         buf[i] = (uint8_t) (rndX >> 15);