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.
Originally posted by Jose Botella:
Alton you are thinking in C , but you should think in Java.
Let nothing stop you! Not even this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton