Remember a silly incident with white thread.
I always feel a little rookie hit the magic bug
Gangster told the debug can not forget
S is null as in FIG.
As FIG ssk.getGwid assigned to the s () is not null
This is a very magical. The first time I met such a case, a little puzzled, ask the chiefs.
The original is affected by multiple threads
ssk I have always been defined in a class, direct
public SocketsFb ssk;
public OutputThread(SocketsFb ssk){
super();
this.ssk=ssk;
}
Changed
public static SocketsFb ssk;
public OutputThread(SocketsFb ssk){
super();
this.ssk=ssk;
}
Ok. Σ (° △ ° |||) ︴
The results are as follows:
This is not the root cause behind the discovery, just to get the value of a coincidence.
In fact, the first time because there is no gwid into this thread, so when s is set to empty, and we clearly see when debug gwid actually get to the second value into this thread, not current set to the value of s. Just sentenced to be empty.
As shown below:
Wu: write code only to understand the technical issues, but also aware of business issues.