What is the relationship between a thread of execution and an object?

R

rubikzube*

If I have an object that has been initialized in one thread of
execution, and I create another thread of execution that calls a method
on that object, does that method execute in the first thread of
execution?

Based on initial observations of thread behavior in an application I am
developing, it does. I'm just looking for some clarification.
 
V

VisionSet

rubikzube* said:
If I have an object that has been initialized in one thread of
execution, and I create another thread of execution that calls a method
on that object, does that method execute in the first thread of
execution?

Based on initial observations of thread behavior in an application I am
developing, it does. I'm just looking for some clarification.

When you call a method from a thread, it executes in that thread period.
So with you example, no, the 2nd thread.
 
J

jmcgill

rubikzube* said:
Based on initial observations of thread behavior in an application I am
developing, it does. I'm just looking for some clarification.

I think you may be misinterpreting your observations.
 
R

rubikzube*

I must be... Hmm. Thanks for the reply. I'm going to go back and take
a closer look at what is going on.
 
R

rubikzube*

Aha! I was calling thread.run() instead of thread.start(). Thank you
for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top