 In single threaded programs all operations appear to have been executed in the order specified, with all out-of-order execution hidden to the programmer – however in multi-threaded environments (or when interfacing with other hardware via memory buses) this can lead to problems.To avoid problems, memory barriers can be used in these cases.The compiler has some freedom to sort the order of operations during compile time.