jQuery in Action, 2nd edition*
The moose likes Sockets and Internet Protocols and the fly likes Collection Class on a Network Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Collection Class on a Network" Watch "Collection Class on a Network" New topic
Author

Collection Class on a Network

Jack Sampson
Greenhorn

Joined: May 08, 2008
Posts: 2
Hi guys, not sure if this should be in the I/O section or here, but here's my problem.

I've created a multithreaded simulation of a producer consumer pattern using a linked blockingqueue, as shown in the javadocs for blockingqueue. It works by having one class with multiple threads each executing a method to add a string to a blockingqueue, another class acting as the blockingqueue and the main method and another class which has threads that take the next string from the queue and prints the contents of that string.

I'd like to have this working over a network, with each class on a separate machine and I was thinking I could have a client that produces the string and writes it to the socket of a server. The server collects all the strings and another client on another machine acts as the consumer and takes from the collection.

I know how to create basic multithreaded servers clients, I'm just stuck with keeping the strings in the correct order and how to take from the queue on the consumer end. Will a buffered input and output stream be sufficient to keep concurrency / synchronization?

Any suggestions of how to accomplish this would be appreciated.
Thanks

Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
I think if you are doing this over a TCP socket, it would be taken care of since it maintains the packet ordering. And since you are already taking care of the ordering in you not n/w based blocking queue, it should work fine.


Thanks and Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Collection Class on a Network