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 3218270
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:30:30+00:00 2026-05-17T15:30:30+00:00

What does it mean when one says no polling is allowed when implimenting your

  • 0

What does it mean when one says no polling is allowed when implimenting your thread solution since it’s wasteful, it has latency and it’s non-deterministic. Threads should not use polling to signal each other.

EDIT

Based on your answers so far, I believe my threading implementation (taken from: http://www.albahari.com/threading/part2.aspx#_AutoResetEvent) below is not using polling. Please correct me if I am wrong.

using System;
using System.Threading;
using System.Collections.Generic;

class ProducerConsumerQueue : IDisposable {
  EventWaitHandle _wh = new AutoResetEvent (false);
  Thread _worker;
  readonly object _locker = new object();
  Queue<string> _tasks = new Queue<string>();

  public ProducerConsumerQueue() (
    _worker = new Thread (Work);
    _worker.Start();
  }

  public void EnqueueTask (string task) (
    lock (_locker) _tasks.Enqueue (task);
    _wh.Set();
  }

  public void Dispose() (
    EnqueueTask (null);     // Signal the consumer to exit.
    _worker.Join();         // Wait for the consumer's thread to finish.
    _wh.Close();            // Release any OS resources.
  }

  void Work() (
    while (true)
    {
      string task = null;
      lock (_locker)
        if (_tasks.Count > 0)
        {
          task = _tasks.Dequeue();
          if (task == null) return;
        }
      if (task != null)
      {
        Console.WriteLine ("Performing task: " + task);
        Thread.Sleep (1000);  // simulate work...
      }
      else
        _wh.WaitOne();         // No more tasks - wait for a signal
    }
  }
}
  • 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-17T15:30:30+00:00Added an answer on May 17, 2026 at 3:30 pm

    Your question is very unclear, but typically “polling” refers to periodically checking for a condition, or sampling a value. For example:

    while (true)
    {
        Task task = GetNextTask();
        if (task != null)
        {
             task.Execute();
        }
        else
        {
             Thread.Sleep(5000); // Avoid tight-looping
        }
    }
    

    Just sleeping is a relatively inefficient way of doing this – it’s better if there’s some coordination so that the thread can wake up immediately when something interesting happens, e.g. via Monitor.Wait/Pulse or Manual/AutoResetEvent… but depending on the context, that’s not always possible.

    In some contexts you may not want the thread to actually sleep – you may want it to become available for other work. For example, you might use a Timer of one sort or other to periodically poll a mailbox to see whether there’s any incoming mail – but you don’t need the thread to actually be sleeping when it’s not checking; it can be reused by another thread-pool task.

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

Sidebar

Related Questions

what does it mean when one says allow exception to propagate upwards to the
xmpp is federated. does that mean that as long as i connected to one
Maybe the worst type of error message that one can see. Does not mean
What does the Linux /proc/meminfo Mapped topic mean? I have seen several one-liners that
Question from the one interview. Please explain what does this C++ code mean: void
using php, if possible. What does it mean? I was reading one of my
Does this mean I can't update another table from a trigger if I'm using
Does it mean search the previous folder for somefile.h or the project folder for
Does [_\s^] mean underscore and whitespace but not (quote) in Reg I understand that
What does _currentHandle() mean below? template<class SpiHandleT> class SpiHandleIterator : public ISpiHandleIterator<SpiHandleT> { public:

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.