Reply to comment

In this particular case... it's irrelevant

There is no such thing (currently) as thread-specific storage in C++. If you were to make m_fibonacci_values static it would result in m_fibonacci_values being shared between all object instances of the class "threaded_class." With the most basic usage case there will only be one "threaded_class" in existence in our application.

If you did make it static *and* you had more than one "threaded_class" it would almost certainly cause a crash as the various objects would step on each other with their shared data...

The confusion you are having may be coming from the function "start_thread" which is static. However, that static method class the non-static do_work and allows for the threads to share m_fibonacci_values.

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • Lines and paragraphs break automatically.
  • You may post PHP code. You should include <?php ?> tags.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Images can be added to this post.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.