some thread code and thinking in java code