Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Send Data to Specific Thread

Posted on 2004-04-29
9
Medium Priority
?
200 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
  • 4
  • 3
7 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

Independent Software Vendors: 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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

824 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