Hi i'm pretty new to the whole java thing with basic skills in the non graphical parts of java and some limited swing skills. There's this thing about threads that's sorta irritating me. I would like to know.....if this is possible....how i can run multiple threads in the same class environment, each of which does something different (ie. has its own run() method). I always implement Runnable because its easier for me so if anyone knows how to do this I would be most appreciative. I have a suspicion that you can't have more than one run() in a given class but if you can, that's what i'd like to do. Thanks :)
asdfgh
0
Newbie Poster
Recommended Answers
Jump to PostYou can use anonymous inner classes. Hardcore Java book has good reasoning for when you should or should not use anonymous inner classes.
For more information about nested inner classes, read Ch 6 of Hardcore Java
Jump to PostThese aren't really subclasses. These are anonymous classes that can exist almost like variables in your code. Notice that I put the statements within a function. Isn't my code snippet example code already?
EdThanks for the reply....so what you're saying is that I must make sort of …
All 6 Replies
asdfgh
0
Newbie Poster
cosi
4
Junior Poster
asdfgh
0
Newbie Poster
cosi
4
Junior Poster
cosi
4
Junior Poster
asdfgh
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.