Is it ok to read a shared boolean flag without locking it when another thread may set it (at most once)?

It is never OK to read something possibly modified in a different thread without synchronization. What level of synchronization is needed depends on what you are actually reading. For primitive types, you should have a look at atomic reads, e.g. in the form of std::atomic<bool>. The reason synchronization is always needed is that the processors … Read more

Monitor vs Mutex

Since you haven’t specified which OS or language/library you are talking about, let me answer in a generic way. Conceptually they are the same. But usually they are implemented slightly differently Monitor Usually, the implementation of monitors is faster/light-weight, since it is designed for multi-threaded synchronization within the same process. Also, usually, it is provided … Read more

What’s the meaning of an object’s monitor in Java? Why use this word?

but I am puzzled why use word “the object’s monitor” instend of “the object’s lock”? See ulmangt’s answer for links that explain the term “monitor” as used in this context. Note that: “Monitors were invented by Per Brinch Hansen and C. A. R. Hoare, and were first implemented in Brinch Hansen’s Concurrent Pascal language.” (Source: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)