标签:ati zed end syn app multiple task ade enc
The most common concurrency problem I‘ve seen, is not realizing that a field written by one thread is not guaranteed to be seen by a different thread. A common application of this:
class MyThread extends Thread {
private boolean stop = false;
public void run() {
while(!stop) {
doSomeWork();
}
}
public void setStop() {
this.stop = true;
}
}
As long as stop is not volatile or setStop
and run
are not synchronized this is not guaranteed to work. This mistake is especially devilish as in 99.999% it won‘t matter in practice as the reader thread will eventually see the change - but we don‘t know how soon he saw it.
what's problem will you face in the multiple threading tasks
标签:ati zed end syn app multiple task ade enc
原文地址:http://www.cnblogs.com/apanda009/p/7932224.html