?
Solved

Send Data to Specific Thread

Posted on 2004-04-29
9
Medium Priority
?
196 Views
Last Modified: 2010-03-31
Ok,I have a program that needs to spawn many threads. The problem is afterwards i need to send some data to only certain threads, not all of them. Or i need to be able to tell the thread to execute a certain method. I have references to all the threads stored in a vector. How can I accomplish this? Thanks in advance,

gf3
gf3@bm3.org
0
Comment
Question by:gf3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10954304
Could you describe what it is you're trying to accomplish with this? What is the overall problem you're trying to solve?
0
 
LVL 1

Author Comment

by:gf3
ID: 10954354
I'm making an AWT based chat application. It isn't a channel based application, it's p2p (so kinda like a one-on-one type of thing). When the user opens a chat with someone a new window (or frame) is started in a new thread and a reference is put in a Vector so i can kepp track of them all. I need to know how to send data the certain threads when the client receives data from the server. Or i need to be able to tell the specific thread to execute a certain method to retreive the data from somewhere. Is there any way of doing this?
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10954542
It sounds like you need to solve two different problems. One is a connection to the server, and the other is the P2P connection between chat participants. If the P2P part is only for 1:1, then it is really easy, if it is for 1:n it becomes a little bit trickier. Is my assumption correct?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:gf3
ID: 10954571
Well it is 1:n, but what do you suggest?
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10954666
I would create a class which handles client requests to the server (which it sounds like you pretty much have right now). Then you would need to create a P2PClient which is capable of communicating with another P2PClient. Are you using TCP or UDP for the network communication?
0
 
LVL 1

Author Comment

by:gf3
ID: 10955651
I'm using TCP, but unsigned applets can only connect to the server that they were spawned off of... so the server has to handle all networking between clients.
0
 
LVL 14

Accepted Solution

by:
Tommy Braas earned 600 total points
ID: 10956794
>>  I'm using TCP, but unsigned applets can only connect to the server that they were spawned off of... so the server has to handle all networking between clients.
Right, I didn't know this was an applet scenario. This of course affects the solution.

I would set it up with one class handling client connection tracking, and another class handling handling P2P communication. You would also want a client class. You also need to define a protocol for client server communication and one for P2P communication.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question