Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Multithreaded Socket Client and Pattern  RSS feed

 
Mik Seiko
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a multithreaded (read and write threads) Applet that uses sockets
to communicate with Server.

Because writer and reader sockets are asynchronous I would like to have
some kind of event based pattern to handle notification when data is fully read or written to socket.

Have anyone of you any suggestion what kind of pattern or structure would
be handy in this kind of issue? I like to hear about your experices.

Cheers,

M.S.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do a publish-subscribe or listener kind of thing. Pass a listener to each new Runnable. The Runnable can call some eventHappened() method on the listener. Are you thinking of something like a display of how many threads are connecting, reading, writing, done?
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case you are using jdk 5, i assume you will be using an Executor. In such a case, you can submit a Future for executing tasks, on which you can inquire whether the task is finished or not.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!