Пример #1
0
        /// <summary>
        /// Returns the pseudo-randomly initialized or updated secondary seed.
        /// Copied from ThreadLocalRandom due to package access restrictions.
        /// </summary>
        internal static int NextSecondarySeed()
        {
            int    r;
            Thread t = Thread.CurrentThread;

            if ((r = UNSAFE.getInt(t, SECONDARY)) != 0)
            {
                r ^= r << 13;                 // xorshift
                r ^= (int)((uint)r >> 17);
                r ^= r << 5;
            }
            else if ((r = java.util.concurrent.ThreadLocalRandom.Current().NextInt()) == 0)
            {
                r = 1;                 // avoid zero
            }
            UNSAFE.putInt(t, SECONDARY, r);
            return(r);
        }