Solved

Send Data to Specific Thread

Posted on 2004-04-29
9
185 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
array11 challenge 16 52
nestparen challenge 4 57
Eclipse Neon and jdk 1.8.0 11 72
base64 decode encode 12 100
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

744 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

12 Experts available now in Live!

Get 1:1 Help Now