Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

10
  • 5
    The only way I know to prevent others from making thread-safe code unsafe is to teach the other programmers the gory details of multi threading, and to document thoroughly the piece of code in stake. Commented Nov 22, 2014 at 8:56
  • 1
    I'm almost positive this could be done in a better fashion, but without knowing how you're using these four variables, it is difficult to provide an alternative solution. This is one of those things that is rather dependent on context I'm afraid. Commented Nov 22, 2014 at 9:12
  • Do you need to share these four variables among the threads? Can you perhaps have local variables and use some kind of message passing to exchange information between the threads? Commented Nov 22, 2014 at 9:37
  • @Neil what are you getting at? I'm just curious if there are any stylistic approaches to keeping everything separate (i.e. namespaces, etc.). Commented Nov 22, 2014 at 14:54
  • 1
    @DocBrown most documentation is an excuse for a poorly designed code/UI/etc. :) I'm trying to see if there's a standard practice to move everything to another file (or whatever practice) or if it just depends on how you want to organize it. Commented Nov 22, 2014 at 14:56