File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Thread question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Thread question" Watch "Thread question" New topic
Author

Thread question

Andy Ceponis
Ranch Hand

Joined: Dec 20, 2000
Posts: 782
Hi,
Im wrote a small program where i had a group of threads that i placed into an array. They all had to do basically the same thing, as each thread represented a person doing an action. Now i want to expand on that program. I would like to write another class that takes another thread and has that thread interact with one of the threads that is in the array. Now my question is this. For one program, can i have more than one run() method? If not then how would get my new thread to do what i want it to do if it has to run in the same run() method? Im probably overlooking something here, so i apologize for seeming slow.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I'm a little puzzled that you say you want the Threads to interact with each other. Do you actually mean call methods on other Thread objects? This is a somewhat strange thing to want to do. It's far more common (and probably more useful) to have all the threads interacting with some shared data items.
Can you clarify a little on what you want to do with these threads?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Andy Ceponis
Ranch Hand

Joined: Dec 20, 2000
Posts: 782
LOL, i just re-read my post and even i have no clue what thats supposed to mean. Sorry. I know what i want to ask, but when i type it out it gets all garbled, hehe.
ok, here is some code from a sample i was given to use as an example.

now the run() method there is where the created array of threads execute. But the new thread i want to have wont be in the array. Instead what it should do is pick one of the threads in the array and get information from it. For example when thread 2 is in the 'eat' state, my new thread would want to print that out. Is that more clear?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread question