libpfrng: use thread-safe approach