i am writing a recording program, when i call a record function,
a thread used for capture the sound is calling to start.
and the code inside the thread's run() is shown below:

recorder = Manager.createPlayer("capture://audio?encoding=amr&rate=8000");
recorder.realize();
rc = (RecordControl)recorder.getControl("RecordControl");
output = new ByteArrayOutputStream();
rc.setRecordStream(output);
rc.startRecord();
recorder.start();
try {
Thread.currentThread().sleep(5000); //record for 5 seconds
} catch (InterruptedException ie) {}
stopRecord();



the above function works well before i have created a timer.

i have created some tasks for the timer in order to display different pictures during recording,
and it is added in this way:

recorderThread.start();
timer.schedule(task1, 1000);

the problem is that the recorderThread will only record for the first one second after i have added the timer.
can anyone tell me the reason and the way to solve it?

Thanks a lot!!