Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3305466
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:10:20+00:00 2026-05-17T21:10:20+00:00

I have a challenging question for you big experts. This has not yet a

  • 0

I have a challenging question for you big experts. This has not yet a practical usage in my code, but comes from an idea I just had.

If I have an IList<T>, how do I implement an enumerator that randomly walks the list and that can be used by multiple threads simultaneously?

For example, if I have elements A, B, C, D, E, F and two concurrent threads performing a for-each loop on the list with a ReaderLock acquired (so I’m sure nobody else will touch the list thus causing an exception), I would like their respective cycles to return, for example, B, E, C, D, A, F and E, B, D, C, A, F.

The reason why I need this is because I need to place locks on List<SslStream> elements to send data to clients, because SslStream is not thread-safe. Picking elements randomly (but making sure I pick them all) reduces the lock conflict probabilities and is supposed to improve I/O-bound operations performance.

Please keep in mind that even if I told you why I need such an enumerator, I still like challenge. There can be other ways of sending the same data to multiple clients, but my question remains the same 🙂 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:10:20+00:00Added an answer on May 17, 2026 at 9:10 pm

    Create an array of the same size as your list, initially populate it as a[i] = i and then shuffle using a Fisher Yates algorithm.

    Your enumerator can then iterate over this array, returning elements from your source list at the random index provided.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a really easy question, so apologies for not being more challenging!
I have been searching the answer to this question for a while. It seemed
While clensing PII from test data I have been stuck with a challenging scenario:
I have a challenging question. My requirement is like i have a xml file
I know very little about regex so this has proven very challenging for me.
This question is challenging to get more understanding on Image Processing using pure C.
This is a different question from the one I just asked and it is
So thanks to many of the replies from this board, I have a much
I'm experiencing a challenging problem, which has not been solvable - hopefully until now.
Have you guys had any experiences (positive or negative) by placing your source code/solution

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.