Buffering is also a factor in your test program. If you had done some kind of flush after echo, there wouldn't have been a 3 second delay before job B saw job A's output. The reason you saw the "42" output immediately is because job A ended, which flushes the buffer. If you had a sleep after the echo 42, then exited, job B would have been delayed again by the sleep amount.
Most languages allow setting buffer sizes and/or enabling line buffering so that flushes occur automagically on line boundaries. As a general rule, stderr is line buffered or not buffered, while stdout has a large buffer.
Most languages allow setting buffer sizes and/or enabling line buffering so that flushes occur automagically on line boundaries. As a general rule, stderr is line buffered or not buffered, while stdout has a large buffer.