What happens when two threads call the same static method at the same time? For example:
public static String someMethod(){
//some logic, can take about 1 second to process
return new String(result);
}
First thread calls someMethod() now. Second thread calls someMethod() 0.5 seconds from now (first thread still processing the data).
I know that someMethod() can be synchronized. But what will happen if it's not synchronized?
static
method doesn't modify the state of a common object used by these threads, then nothing wrong will happen. – Kistner