> Hi,
>
[quoted text clipped - 27 lines]
> Thanks in advance
> -Sundar
Does it have to run on pre-1.5 versions of Java?
If not, look at java.util.concurrent, especially the blocking queues.
They seem ideal for the message passing model of thread communication,
and you expressed your problem in terms of message passing.
Patricia
Lew - 11 Nov 2006 19:20 GMT
>> Hi,
>> There are three threads in the player.
[quoted text clipped - 11 lines]
>> the master thread.
>> Till this message is recieved the master thread should wait.
> ... look at java.util.concurrent, especially the blocking queues.
> They seem ideal for the message passing model of thread communication,
> and you expressed your problem in terms of message passing.
If your algorithm is completely synchronous, how will threads help you?
public void play( String audioFile, int blockSize ) // untested
{
FileChannel fc = new FileInputStream( audioFile ).getChannel();
for ( ByteBuffer buffer = ByteBuffer.allocate( blockSize );
fc.read( buffer ) >= 0L; buffer.clear() )
{
buffer.flip();
play( buffer );
}
}
- Lew
- Lew
> Hi,
>
[quoted text clipped - 27 lines]
> Thanks in advance
> -Sundar
java.io.PipedInputStream
java.io.PipedOutputStream
explicit data passing between threads.
or you can use synchronized blocks of code in each thread and use wait
and notify to set variables at appropriate times.
Sundar - 11 Nov 2006 06:41 GMT
Thanks for your help.
I took a look into wait() and notify() mothods. Im got stuck and i
could not find a way to use wait and notify. Is there any code snippets
availabe which gives the example of wait and notify methods??
Thanks in advance
-Sundar
> > Hi,
> >
[quoted text clipped - 35 lines]
> or you can use synchronized blocks of code in each thread and use wait
> and notify to set variables at appropriate times.
Gordon Beaton - 11 Nov 2006 08:51 GMT
> java.io.PipedInputStream
> java.io.PipedOutputStream
>
> explicit data passing between threads.
That's just silly. There's no need to *stream* data between threads
when you can pass object references or simply call methods in the
target thread.
/gordon

Signature
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e