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 / C++ / MFC
  4. How to Kill the Worker Thread ?

How to Kill the Worker Thread ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++iostutorialquestion
23 Posts 6 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.
  • D David Crow

    ParagPatel wrote:

    if(stopTh == true)

    Unless stopTh is volatile, the compiler will optimize out this check.

    "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

    P Offline
    P Offline
    ParagPatel
    wrote on last edited by
    #21

    Thanks , Yes.. stopTH must be globle or thread function must use through passed class object.

    Parag Patel Sr. Software Eng, Varaha Systems

    D R 2 Replies Last reply
    0
    • P ParagPatel

      Thanks , Yes.. stopTH must be globle or thread function must use through passed class object.

      Parag Patel Sr. Software Eng, Varaha Systems

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #22

      ParagPatel wrote:

      Thanks Simmons,

      :confused:

      ParagPatel wrote:

      Yes.. stopTH must be globle

      Being global has nothing to do with it. If the compiler detects that nothing in the loop is changing that variable, it will optimize out the check. So even if the secondary thread changes that variable, it will go unseen.

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      1 Reply Last reply
      0
      • P ParagPatel

        Thanks , Yes.. stopTH must be globle or thread function must use through passed class object.

        Parag Patel Sr. Software Eng, Varaha Systems

        R Offline
        R Offline
        Rajesh R Subramanian
        wrote on last edited by
        #23

        Changing it through the class object = changing it from a different thread (the main thread of the app). Which means it will be optimized away.

        It is a crappy thing, but it's life -^ Carlo Pallini

        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