There's a simple stupid question that bother me and make several arguments in my mind.
I want to throw out all the doubts about below questions.
class Clstest{
public static String testStaticMethod(String inFileStr) {
// section 0
// section 1
// do something with inFileStr
// section 2
// section 3
return inFileStr;
}
}
Let's assume there are five threads are each executing a call to Clstest.testStaticMethod("arg-n")
at the same time.
Thread 1 calls Clstest.testStaticMethod("arg-1")
.
When thread 1 is in the section 1, thread 2 calls Clstest.testStaticMethod("arg-2")
.
Then what will happen to Thread 1? Will it go to sleep state?
When Thread 1 got the chance will it resume the execution from section 1 where it was paused?
How it happens when there's one Clstest.testStaticMethod
and same Clstest.testStaticMethod
is shared between all five threads?
Is there any possibility to interchange the inFileStr
sent by multiple threads?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…