David Spades wrote:
first of all, is there any chance that this program will ouput the line "A Hello!"? I always got "B Hello!".
if it'll never print "A Hello!", could anybody explain why?
Scheduling of threads is not defined by the JVM specification. This is mainly to allow the native threading system to schedule threads as they like. This is also true with the use of condition variables (ie. wait/notify).
So, to answer your question... The behavior is not defined.