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. A question about thread programming

A question about thread programming

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
2 Posts 2 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.
  • C Offline
    C Offline
    Chaos Lawful
    wrote on last edited by
    #1

    Here is a class which I want to use in a multi-threaded program: class threadclass { public: void A(); void B(); }; void threadclass::A() { B(); } void threadclass::B() { } UINT WINAPI threadproc(LPVOID lpData) { threadclass xx; xx.A(); return 0; } I use it like this: CWinThread *pThread=AfxBeginThread(threadproc,NULL); Will there be some error occured? Is the class thread-safe? :confused: Law is meaningless without chaos. Chaos without Law is equal to destruction. Chaos and Law create our rich and colorful world.

    J 1 Reply Last reply
    0
    • C Chaos Lawful

      Here is a class which I want to use in a multi-threaded program: class threadclass { public: void A(); void B(); }; void threadclass::A() { B(); } void threadclass::B() { } UINT WINAPI threadproc(LPVOID lpData) { threadclass xx; xx.A(); return 0; } I use it like this: CWinThread *pThread=AfxBeginThread(threadproc,NULL); Will there be some error occured? Is the class thread-safe? :confused: Law is meaningless without chaos. Chaos without Law is equal to destruction. Chaos and Law create our rich and colorful world.

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      Aren't you missing anything in the exposition of your problem? The class is trivially thread safe, basically because it does nothing. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      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