Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Threading Question

Threading Question

Scheduled Pinned Locked Moved C#
data-structuresquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tristan Rhodes
    wrote on last edited by
    #1

    Is there any way, when implementing a lock, that an incoming thread can force its own priority over the ones currently queued? i.e. i've got 10 threads waiting to add items to a stack, and a thread that copies, empties and leaves the lock to process the copied items. I don't want to wait N milliseconds for the items to be added to the stack as the processing thread is a priority, so i want the processing thread to jump to the front of the lock queue. Is this possible? And how could i do it? Cheers guys Tristan Rhodes

    N A 2 Replies Last reply
    0
    • T Tristan Rhodes

      Is there any way, when implementing a lock, that an incoming thread can force its own priority over the ones currently queued? i.e. i've got 10 threads waiting to add items to a stack, and a thread that copies, empties and leaves the lock to process the copied items. I don't want to wait N milliseconds for the items to be added to the stack as the processing thread is a priority, so i want the processing thread to jump to the front of the lock queue. Is this possible? And how could i do it? Cheers guys Tristan Rhodes

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Interesting quesiton. I don't believe setting the thread priority has anything to do with the acceesing the lock, I thought it was a FIFO construct. Never really thought about type of situation though.


      only two letters away from being an asset

      1 Reply Last reply
      0
      • T Tristan Rhodes

        Is there any way, when implementing a lock, that an incoming thread can force its own priority over the ones currently queued? i.e. i've got 10 threads waiting to add items to a stack, and a thread that copies, empties and leaves the lock to process the copied items. I don't want to wait N milliseconds for the items to be added to the stack as the processing thread is a priority, so i want the processing thread to jump to the front of the lock queue. Is this possible? And how could i do it? Cheers guys Tristan Rhodes

        A Offline
        A Offline
        Ami Bar
        wrote on last edited by
        #3

        I did something similar when I implemented my SmartThreadPool. Check my article: http://www.codeproject.com/cs/threads/smartthreadpool.asp[^]. I implemented a special queue that items are queued FIFO, but waiters queue LIFO. You can change the code to get what you want. Ami

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups