Thread: Program shows different behavior each time it's run

  1. #16
    Tweaking master Aslaville's Avatar
    Join Date
    Sep 2012
    Location
    Rogueport
    Posts
    528
    Quote Originally Posted by -Adrian View Post
    1. These are non-const class members, so aside from passing them into the solve method (is that common practice?) that won't be possible.
    2. If you mean move auto to line 10, wouldn't that cause the compiler to create a new object each iteration or is that irrelevant since find produces one anyway? I usually try to construct re-used variables before the loop, but if that's not the best approach, let me know.
    1. I was just noting something general not with reference to your current code.
    2. In that case I might be sure which way is best, I guess you could just stick to your current one.

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by -Adrian View Post
    Yeah, I left that part out in my original post. I have multiple threads writing to "M" (mutex locked) and since they start in sequence with some delay between each and consume the same amount of data, I assumed they would always finish in the exact order they started. Not always so.
    I'm guessing you've learned the lesson now, but don't ever assume the order of execution of threads unless you're building a pipeline.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #18
    Informer -Adrian's Avatar
    Join Date
    Jan 2013
    Posts
    820
    Yeah, that's true. However, the order of thread execution wasn't on my radar because it didn't matter to the program I thought I was writing. It only started to matter when finding the source of the problem, which were the duplicate keys in the input.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange program behavior
    By milli-961227 in forum C++ Programming
    Replies: 5
    Last Post: 04-05-2015, 11:57 AM
  2. Replies: 5
    Last Post: 04-17-2013, 11:32 PM
  3. Replies: 2
    Last Post: 04-17-2013, 12:25 AM
  4. Very strange behavior from very simple program
    By somekid413 in forum C Programming
    Replies: 5
    Last Post: 12-17-2009, 08:53 PM
  5. Program that shows biggest line...
    By i_can_do_this in forum C Programming
    Replies: 6
    Last Post: 07-21-2006, 07:56 AM

Tags for this Thread