Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9114435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:12:00+00:00 2026-06-17T04:12:00+00:00

I have been trying to learn about threads via the Windows API. I ran

  • 0

I have been trying to learn about threads via the Windows API. I ran across __declspec( thread ) from msdn, but I don’t understand what the difference is between that and CreateThread().

It sounds like you only create the thread on the object? Does that mean that if I wrote a method that does while(1); and ran that method in my main class through that object, it would do that in a separate thread? I guess my question is what is __declspec ( thread ) used for, and should I use that over CreateThread?

Sorry if my question is confusing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:12:01+00:00Added an answer on June 17, 2026 at 4:12 am

    The difference between them is huge:

    • __declspec( thread ) is a storage modifier that specifies that the declared variable has local storage. That means that each thread owns its own copy of this value. Is the threaded version of globals.

      C++11 introduces thread storage modifiers by the name thread_local. Its a storage modifier, like static.

    • CreateThread() is a function that will create a new thread and start running some function you specify.

      C++11 also introduces an entire threading API that you can use to write thread-aware code that will run on (almost) any platform. You can search for std::thread and std::async…

    So basically they are two entirely different things, used for entirely different purposes. If you want to create a new thread using the Windows API then use CreateThread. If you want a variable to have thread_local storage using the Windows API then use __declspec( thread ). If you can use C++11, you should forget about the subtleties of the Windows API and use the Standard API instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn more about the DOM and have been writing some
I have been trying to learn about resources and styles, I want to create
I have been trying to learn about dependency injection and have been reading about
I've been trying to learn python recently, and ran across something that I'm having
I am somewhat new to jQuery but have been having fun trying learn about
I have been trying to get mysql entries to update via php from ios.
I have been trying to learn a bit more about delegates and lambdas while
I am trying to learn more about Javascript, I have been coding with PHP
I have recently been trying to learn about basic design principles and the OCP
I have been trying to learn more about lambda expressions lately, and thought of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.