In concurrent programming, a race condition occurs when two or more processes or threads compete to access shared resources, and the outcome of their execution depends on the unpredictable order in which they execute. This can lead to unexpected behavior or bugs, as the result can change depending on the timing of thread execution.
- When two processes compete for CPU time (A) is related to the concept of CPU scheduling, but it is not specifically a race condition.
- When a program terminates unexpectedly (C) is an error that can happen for various reasons, but it is not necessarily related to race conditions.
- When memory allocation fails during execution (D) is an issue with memory management, not a race condition.
Thus, the correct answer is (B), where the outcome depends on thread execution order.