Originally posted by Marlene Miller:
If you want two new threads, you *must* create two new Thread objects. Every thread has its own Thread object to manage that thread.
A th1 = new A();
A th2 = new A();
When a thread executes an instance method, the thread stack has a pointer(*) to some object data on the heap.
So for example, the parent thread opens a file, and then creates 2 threads that will read/write on that file, it has to explicitly pass that file object to the 2 threads. Those 2 threads cannot just grab it from the parents memory.
SCJP2. Please Indent your code using UBB Code
Originally posted by Jose Botella:
Alton you are thinking in C , but you should think in Java.![]()
![]()
Look ma! I'm selling my stuff!
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
|