2 ms·
Even if you were using the [identity] equality operator in Java, since the question asks if it could "ever evaluate to true", the answer is also yes if another
by kodablah 9y ago
Even if you were using the [identity] equality operator in Java, since the question asks if it could "ever evaluate to true", the answer is also yes if another thread is updating the var during the if check.
- _nalply 9y agoThis could perhaps happen within async functions when you have await's interleaving. Or in server-side Meteor code because of fibers. But not in the browser in non-async functions because JavaScript is single-threaded, especially inside a compound expression.
- anfractuosity 9y agoJust tried it in C with a thread, which did work like you say. int a = 1; void *brute(void *vargp){ while(1) { a = 1; a = 2; a = 3; } } int main(){ pthread_t tid; pthread_create(&tid, NULL, brute, NULL); while(1){ if( a == 1 && a == 2 && a == 3 ){ printf("woo\n"); return; }else{ printf("fail\n"); } } }
- zethraeus 9y agoThis is a good answer to the terrible question. Nice.