I think Lorand Komaromi gave a good hint for that -- so the overall threading routine could look like following:
current thread owns stack1, the new thread will own stack2, they both share the same heap
Runnable rr = ... // variable rr lying on stack1 gets a reference to the object lying on heap which contains the method "run"
Thread t = new Thread(rr, "SomeName"); // variable t lying on stack1 gets a reference to the newly created thread object
. The thread inside has a reference to the instance of object with "run" method, and that object lies on heap (not stack1 nor stack2)
t.start(); // the JVM starts new thread of execution
, and executes the method of the object lying on heap.
So, answers could be (in my opinion):
Thread t= Thread.currentThread();
//does this statement implies that we passing the address of stack pointer of current stack frame of seprate call of stack in t?
"Correct me if i am wrong"?
This line of code assigns t with a reference to the Thread object
representing the current thread of execution
. It is the reference to the object lying on common heap.
t = new Thread
(Runnable threadob,"threadname");//since threadob only have acess to run function extend in class that implements runnalbe interface,so we passing the address of that run function in thread t,which define where execution of thread ll begin?
In this case, we are not passing the address of function (method), but reference to the heap where instance of Runnable
exists (actually instance of some object implementing Runnable, but who cares...). The thread of execution
will take this object from heap
and executes it's run method.
I make a guess that you have been a programmer of C/C++/Delphi, haven't been?