JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java 程式分享區 » Networking  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 Re:[網路]多人聊天伺服器 v0.3 [Re:caterpillar]
T55555

Java, Ruby, Haskell

版主

發文: 1026
積分: 24
於 2004-03-31 23:48 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
caterpillar wrote:
近來在整理多執行緒的一些心得,結果。。。。哈!發現這個程式有個非常好笑的錯誤,不過我不修正,看有沒有人可以找出來的並公佈修正版本的!修正錯誤的可以加分喔!(加分作什麼?問站長吧!反正先加再說,以後有利多時就用的上了。。。。Big Smile

提示:如果有很多訊息時就很好笑了。。。。不是之前討論的LinkedList與Vector的問題。。。。。


個人淺見:
我不知道這是不是個錯誤. 我只是覺得會有這現象...
In BroadCastThread.run()
the thread is sleep 2 seconds and broadcast a message to all clients. (only one message at a time)
If there are many clients, and many messages need to be broadcast,
the message may wait long long time to broadcase.

For example, if the message vector is empty, and during the 2 seconds (thread sleep time) there are 10 clients, each one types 50 messages, ==> Ooops,
if you type a new message, then you have to wait, at least, 10 * 50 * 2 = 1000 seconds = ~17 minutes later then your message will be broadcast.

More and more clients, more and more messages waiting, more and more this phenomena worst.

(And of course, if there is a "robot" to type quickly the message in secondes, make the Vector out of limited or Out of memory error ... Ooops...)

Solution: Make a MAX_SIZE to allows in message vector,
check and return boolean result or throw exception,
let the client know about the server is in "overflow" state,
please wait and retry later to post new message ...

(Idea: And it is maybe good too, like, fix a maximum number of active client connected allowed. And/Or do something like "time out disconnect" if the client do not post a new message during an amount of time ...)

( BTW: 我 13分很久了... Smile )


T55555 edited on 2004-04-01 00:21
reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
37325 [精華] [網路]多人聊天伺服器 v0.3 caterpillar 12420 2004-03-02 19:04
26089 Re:[分享]多人聊天伺服器 v0.3 popcorny 89 2004-03-02 22:45
4537 Re:[網路]多人聊天伺服器 v0.3 summerdan 24 2010-11-05 13:10
25844 Re:[分享]多人聊天伺服器 v0.3 caterpillar 382 2004-03-02 23:50
25580 Re:[分享]多人聊天伺服器 v0.3 popcorny 650 2004-03-03 01:02
25407 Re:[分享]多人聊天伺服器 v0.3 ahan 251 2004-03-03 18:26
25376 Re:[分享]多人聊天伺服器 v0.3 caterpillar 193 2004-03-03 18:49
25274 Re:[分享]多人聊天伺服器 v0.3 ahan 249 2004-03-03 19:11
25407 Re:[分享]多人聊天伺服器 v0.3 caterpillar 227 2004-03-03 19:23
25104 Re:[分享]多人聊天伺服器 v0.3 popcorny 229 2004-03-03 19:25
26333 Re:[分享]多人聊天伺服器 v0.3 caterpillar 256 2004-03-03 19:30
25244 Re:[分享]多人聊天伺服器 v0.3 ahan 231 2004-03-04 01:05
25980 Re:[網路]多人聊天伺服器 v0.3 genjen62 318 2004-03-26 13:42
26300 Re:[網路]多人聊天伺服器 v0.3 caterpillar 170 2004-03-31 18:19
25340 Re:[網路]多人聊天伺服器 v0.3 T55555 1510 2004-03-31 23:48
24891 Re:[網路]多人聊天伺服器 v0.3 caterpillar 138 2004-04-01 00:28
24688 Re:[網路]多人聊天伺服器 v0.3 T55555 1660 2004-04-01 01:28
24813 Re:[網路]多人聊天伺服器 v0.3 T55555 3054 2004-04-01 02:10
25051 Re:[網路]多人聊天伺服器 v0.3 contagious 1760 2004-04-01 14:42
23925 Re:[網路]多人聊天伺服器 v0.3 blowfish 167 2004-05-28 16:27
26844 Re:[網路]多人聊天伺服器 v0.3 caterpillar 129 2004-05-28 19:15
4852 setMessageObserver()請問觀察者是什麼意思??? object0625 165 2010-06-03 00:21
» JWorld@TW »  Java 程式分享區 » Networking

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8