This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes parameter in threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "parameter in threads" Watch "parameter in threads" New topic

parameter in threads

Mario Gimenez
Ranch Hand

Joined: Mar 23, 2010
Posts: 38
I don't know how put a parameter for something like this:


this its possible??

Anybody knows another way to do this???

Thanks in advance...
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

What you do want? Do you want to pass an integer to a method? Yes that is possible :P

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Ireneusz Kordal
Ranch Hand

Joined: Jun 21, 2008
Posts: 423
Mario Gimenez
Ranch Hand

Joined: Mar 23, 2010
Posts: 38
Here is the project how send one message.

Now I want to use this to send many messages (whit threads or another ways....),
Because I need change a part of the message in each call I need pass a string parameter via Thread.
Because I need to know if its possible pass a String parameter to a thread.

for example...

for (x= 0; x< 50; x++){
Thread t = new Thread(x);


MyClass mc = new MYclass();

mc.sendMessage(x); ----> this method it will replace the main method in the code I wrote before.

I hope I describe my doubt.

Thanks a lot.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20136

Is reading really that hard? Ireneusz has just about given you the complete answer, over 12 hours before your post.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: parameter in threads
It's not a secret anymore!