Solved

Send Data to Specific Thread

Posted on 2004-04-29
9
186 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 150 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now