java threads don't make sense
1 posts in topic
Flat View  Flat View

Posted By:   mark_norman
Posted On:   Tuesday, July 31, 2001 09:58 AM

I think the way threads are done in Java does not make sense. Please tell me your opinion. In Java, a thread is always associated with an object: The constructor for the Thread class takes an object as its argument. The problem with this is that each object can only have one run() method. What if there are several points in the methods of your class that should be multi-threaded? You are forced to pull those methods out of your class and put them in separate classes so that they too can be run in separate threads. What the designers of Java should have done is to associated a thread with a method, not an object! This is the way threads are implemented in the non-Java world. Your opinions, please!

Re: java threads don't make sense

Posted By:   Alex_Chaffee  
Posted On:   Thursday, August 2, 2001 10:50 AM

> The constructor for the Thread class takes an object as its argument.

No it doesn't. You should read the docs more carefully.

To your point, you can easily use inner classes to launch as many threads as you want "inside" an object -- each child thread will have access to the parent object's instance variables.

A thread's run() method is merely the starting point for a new thread's life inside the Java VM. Where it goes from there is entirely up to you.

About | Sitemap | Contact