The Artima Developer Community
Sponsored Link

Java Answers Forum
Sharing data in threads

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
lorre

Posts: 1
Nickname: lorre
Registered: Mar, 2003

Sharing data in threads Posted: Mar 1, 2003 7:43 AM
Reply to this message Reply
Advertisement
hi,
I writing a multi-user chat application and need some help.
can anyone tell me why this functions only prints the first name (first connected client) and not the rest ?

code:
-----

public void setClientInfo(String info)
{

StringTokenizer st = new StringTokenizer(info);
int tel = st.countTokens();
System.out.println(tel);
name = st.nextToken();
sex = st.nextToken();
while(st.hasMoreTokens())
{
brol = st.nextToken();
}

synchronized(whoOnline)
{
whoOnline.addElement(new ClientInfo(name,sex,brol));
}
}

public void printAllOnlineClients()
{
System.out.println(chatters.size()+":"+chatters);
System.out.println(whoOnline.size()+":"+whoOnline);

for(int i = 0; i < chatters.size(); i++)
{

synchronized(chatters)
{
//String online = (String)whoOnline.elementAt(i);
synchronized(whoOnline)
{
Chatter sendMessage = (Chatter)chatters.elementAt(i);
for(int y = 0; y < chatters.size(); y++)
{
ClientInfo temp = (ClientInfo)whoOnline.elementAt(y);
sendMessage.out.println(temp.name);// + "\r");
sendMessage.out.flush();
}

}

}
}
}


if you need more code to solve it or to get a clearer view, just ask here, or email me for complete code =>levawa@vt4.net
or contact me through icq :108862592
i much appreciate the help

cu

Topic: JDO Question Previous Topic   Next Topic Topic: Random Number Problem

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use