Suppose below code:
Class test
{
void foo()
{
int i=0;
}
}
Test t=new Test();
// if many threads call t.foo();
Does each thread has its own memory for calling foo? It means each thread has it's own i
?
How does Java/C# allocate memory when it calls the function?
As I remember, in C#, each thread will be allocated 1M memory. What about Java?
Copyright Notice:Content Author:「roast_soul」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/15424542/how-does-java-c-allocate-memory-when-multiple-threads-call-same-functions