I haven't looked carefully but I suspect that you want notifyAll() instead of notify()
G. Blake Meike Marakana The second edition of Programming Android is now on-line: http://shop.oreilly.com/product/0636920023005.do On May 24, 8:05 pm, yikaikai <[email protected]> wrote: > I have two thread, one for receive network video steam, another for > handle the stream, but after some round, I cannot got anything, below > is my code, what's the problems? THX > > class ReceiveThread extends Thread > { > int FLAG = 0; > > public void run() // ReceiveThread > { > long count = 0; > > while (true) { > count++; > synchronized(obj) { > while (FLAG > != 0) { > try { > Log.d(" Producter > Waiting", ".........."); > obj.wait(); > } catch (InterruptedException > e) { > // TODO Auto-generated > catch block > e.printStackTrace(); > } > } > Log.d("Producter", "1 count" + count); > > ...................................................................... > FLAG = 1; > obj.notify(); > > } > > } > > } > > } > > class PlayView extends View implements Runnable > { > > private ReceiveThread mReceiveThread = null; > > public void PlayVideo(String file) > { > mReceiveThread.start(); > new Thread(this).start(); > > } > > public void run() // play Video > { > while (true) { > synchronized (mReceiveThread.obj) { > > while (mReceiveThread.FLAG != 1) { > try { > Log.d(" Consumer > Waiting", ".........."); > > mReceiveThread.obj.wait(); > } catch (InterruptedException > e) { > // TODO Auto-generated > catch block > e.printStackTrace(); > } > } > Log.d("Consumer", "0"); > ...................................... > mReceiveThread.FLAG = 0; > mReceiveThread.obj.notify(); > > } > > } > > } > > here is the log: > > ... > ... > 05-25 02:29:23.897: D/Producter(361): 1 count367 > 05-25 02:29:23.897: D/Receive Waiting(361): .......... > 05-25 02:29:23.897: D/Consumer(361): 0 > 05-25 02:29:23.897: D/Producter(361): 1 count368 > 05-25 02:29:23.897: D/Receive Waiting(361): .......... > 05-25 02:29:23.897: D/Consumer(361): 0 > 05-25 02:29:23.909: D/Producter(361): 1 count369 > 05-25 02:29:23.909: D/Receive Waiting(361): .......... > 05-25 02:29:23.909: D/Consumer(361): 0 > 05-25 02:29:23.927: D/Producter(361): 1 count370 > 05-25 02:29:23.927: D/Receive Waiting(361): .......... > 05-25 02:29:23.927: D/Consumer(361): 0 > 05-25 02:29:23.927: D/Producter(361): 1 count371 > 05-25 02:29:23.937: D/Receive Waiting(361): .......... > 05-25 02:29:23.937: D/Consumer(361): 0 > 05-25 02:29:23.937: D/Producter(361): 1 count372 > 05-25 02:29:23.937: D/Receive Waiting(361): .......... > 05-25 02:29:23.948: D/Consumer(361): 0 > 05-25 02:29:23.948: D/Producter(361): 1 count373 > 05-25 02:29:23.948: D/Receive Waiting(361): .......... > 05-25 02:29:23.948: D/Consumer(361): 0 > 05-25 02:29:39.252: V/HeartBeat Thread:(361): Thread-9Thread Num: 6 > 05-25 02:30:09.372: V/HeartBeat Thread:(361): Thread-9Thread Num: 6 > 05-25 02:30:39.446: V/HeartBeat Thread:(361): Thread-9Thread Num: 6 > 05-25 02:31:09.529: V/HeartBeat Thread:(361): Thread-9Thread Num: 6 > 05-25 02:31:39.667: V/HeartBeat Thread:(361): Thread-9Thread Num: 6 > ... > .... > > why the receive and playview not working ? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

