• Post Reply Bookmark Topic Watch Topic
  • New Topic

Implementing Piped Streams  RSS feed

 
Scott Krasnigor
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am playing around with a multi-threaded rule-based application. I have one thread reading data from a file doing some processing and then passing the data on to a control thread. The control thread evaluates the data against a set of rules and passes the data onto other processing threads based on the results of it's evaluation. I have been reading up on PipedInputStream/PipedOutputStream and want to implement this type of thread communication but am having trouble getting my head around it. I wanted to create 2 classes - PipedInputThread and PipedOutputThread, then create instances of these as needed. Does this make sense? If so, how would I write a generic run() method for the classes? Thanks in advance for any help.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to the ranch!

The piped streams are good if streams carry your data easily. I had an example using them but the ranch seems to have dropped postings more than a few days old. I'll see if I can dig it up.

I also made something to send objects through a series of pipe stages using blocking queues from JDK 5. Each pipe stage reads from one or more queues and writes to one or more queues. Here's a typical test that sends around strings "one", "two" etc. You'll have to imagine some of the methods in the superclass. NullPipeTask just copies input to output. If it looks interesting I can bundle it up to share:

[ October 11, 2005: Message edited by: Stan James ]
 
Scott Krasnigor
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. If I understand right, the piped streams don't pass objects? I have a track class and need to pass instances of a track between the threads. If the piped streams won't pass the data I want, then I am interested in checking out your solution. I will enable my email in case you would rather send it vice posting it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!