none
threads in visual c++ 2008 (openmp) RRS feed

  • Question

  • how can i create threads in visual C++? (i have to do a mini project in openmp(parallel programming and multi threading))

    So i now have openmp along with visual studio 2008 in my system..

     

    now inorder to proceed further i need to know how to actually create threads (say 2 threads) in visual c++ and assign a task and run it...

    i.e. in a project of type "win32 console application" and configured to support openmp , (this is because i need to use openmp directives later in my program) how to create two(say for e.g.) threads and run it parallel?

     

    right now i know how to configure a project to support openmp, and i have some knowledge in C,C++ and know some stuffs regarding threads theoritically (very little practical knowledge about threads, i googled for some time but it was useless, so thought of posting it here)

     

    so can any one help me in creating threads..


    - Vinay
    Sunday, October 31, 2010 10:32 AM

Answers

  • jaki chan wrote:
    >
    >how can i create threads in visual C++? (i have to do a mini project
    >in openmp(parallel programming and multi threading))
     
    Well, you use the CreateThread API to create threads in Windows, but if
    you're using OpenMP, you probably want to let OpenMP do that. If you use
    "#pragma omp" properly, it will create and manage the threads
    automatically.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, DDK MVP
    Tuesday, November 2, 2010 5:14 AM