Skip to content
Discussion options

You must be logged in to vote

@MBurtsev another way to get the same 'random' distribution is to have something like

public class RoundRobbin{

    private static int _current=0;
    private static int GetNext => System.Threading.Interlocked.Increment(ref _current);
    
    static void Test()
    {
        var threadId = GetNext % Environment.ProcessorCount;
    }
}

Replies: 6 comments 54 replies

Comment options

You must be logged in to vote
4 replies
@yaakov-h
Comment options

@MBurtsev
Comment options

@yaakov-h
Comment options

@MBurtsev
Comment options

Comment options

You must be logged in to vote
1 reply
@MBurtsev
Comment options

Comment options

You must be logged in to vote
13 replies
@theunrepentantgeek
Comment options

@MBurtsev
Comment options

@MBurtsev
Comment options

@CyrusNajmabadi
Comment options

@CyrusNajmabadi
Comment options

Comment options

You must be logged in to vote
27 replies
@CyrusNajmabadi
Comment options

@MBurtsev
Comment options

@CyrusNajmabadi
Comment options

@tannergooding
Comment options

@MBurtsev
Comment options

Comment options

You must be logged in to vote
8 replies
@MBurtsev
Comment options

@MBurtsev
Comment options

@CyrusNajmabadi
Comment options

@HaloFour
Comment options

@MBurtsev
Comment options

Comment options

You must be logged in to vote
1 reply
@MBurtsev
Comment options

Answer selected by MBurtsev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
10 participants
Converted from issue

This discussion was converted from issue #6181 on May 29, 2022 13:49.