How to know if a VS2008 project supports multithread or not?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: How to know if a VS2008 project supports multithread or not?

  1. #1
    Join Date
    Nov 2010
    Posts
    52

    How to know if a VS2008 project supports multithread or not?

    Hi,

    I get a VC2008 project with full source. How to know whether it supports multithread or not? I think as long as the “Runtime Library” under “C/C++” - “Code generation” category is set to “Multi-threaded”, then the project should be thread-safe, is that correct? Or are there any other project settings need to be checked?

    Thanks

    Alan

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,604

    Re: How to know if a VS2008 project supports multithread or not?

    “Multi-threaded” category does NOT mean that "the project should be thread-safe", but only it "supports multithread".
    It is up to project developer to do a project to be "thread-safe" or not.
    Victor Nijegorodov

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,070

    Re: How to know if a VS2008 project supports multithread or not?

    Quote Originally Posted by AlanCCC View Post
    I think as long as the “Runtime Library” under “C/C++” - “Code generation” category is set to “Multi-threaded”, then the project should be thread-safe, is that correct? Or are there any other project settings need to be checked?
    This runtime setting is exactly what it says: C Runtime multithreading.

    And there is no setting that would turn on or off multithreading for entire project, as any Windows process natively supports multithreading. You can create a multithreaded program even when linking to single threaded runtime, you just have to be careful enough to not use runtime objects across threads bounds.

    And to the point of being thread safe, I agree with Victor, it's strictly up to programmer to make it be that, as C/C++ knows nothing about threads.
    Best regards,
    Igor

  4. #4
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,840

    Re: How to know if a VS2008 project supports multithread or not?

    Certain functions (eg _beginthreadex) are only declared in the header file if the code generation is set to 'Multi-threaded'.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  5. #5
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,100

    Re: How to know if a VS2008 project supports multithread or not?

    popping a few myth bubbles here...

    _EVERY_ program you write for windows inherently supports multithreading. All it takes is create the extra threads either through the windows API functions, the runtime lib or some other library that allows you to do so.

    Even if you don't make any extra threads in your own code. The OS dll's itself, drivers, hooks etc can all create additional threads.

    So your answer is sort of a bogus one, it is literally impossible (other than hacking deep into the OS kernel) to create an application on windows that will guarantee that at no time during it's runtime no additional threads can ever be created.


    Even if you compile your program as non-MT. You can still create threads and do so safely, one restriction is going to be that the thread cannot use (some of) the runtime library functions.
    Regardless, you're always subject to whatever libs you are using and to what degree those libraries support being called from multiple threads at the same time.

    Most of the windows API is fully MT enabled (part of it isn't), but that doesn't mean you can safely access a single resource simultaneously.

    Any time you access a single resource/memory/object/handle/something from 2 threads at the same time, you're Always going to need to ask the question if doing so is thread safe.

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,471

    Re: How to know if a VS2008 project supports multithread or not?

    Quote Originally Posted by OReubens View Post
    So your answer is sort of a bogus one.
    Which answer is bogus?

  7. #7
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,100

    Re: How to know if a VS2008 project supports multithread or not?

    Typo: I meant a bogus/meaningless QUESTION.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center