Jump to content
  • Advertisement
Sign in to follow this  
Floating

How to find out which thread is currently running

This topic is 4441 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, How can I find out about which thread I am currently in? I start my threads like: AfxBeginThread(thread1,NULL,THREAD_PRIORITY_NORMAL); AfxBeginThread(thread2,NULL,THREAD_PRIORITY_NORMAL); Is there some global variable that I could maybe check? Or some function that I can call? Thanks

Share this post


Link to post
Share on other sites
Advertisement
If the code from the thread1 function is being run then you're in that first thread. If the code from the thread2 function is being run then you're in the second thread. That's really all you have to go by - if you're not in that function then you're not in that thread.

Share this post


Link to post
Share on other sites
Quote:
Original post by Colin Jeanne
If the code from the thread1 function is being run then you're in that first thread. If the code from the thread2 function is being run then you're in the second thread. That's really all you have to go by - if you're not in that function then you're not in that thread.


Yes, but what if both threads call a common function?? Then from within that function I can't know which thread called it!

Thanks LessBread, that's what I was looking for :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!