0

I want to start two threads at the same time. A thread that receives a video and stores it on the smartphone and one that plays the video. Neither are getting but it works separately. How can i do this?

 public void startProgress(View view) {
    ConcurrentLinkedDeque<OutputStream[]> list = new ConcurrentLinkedDeque<>();

  /*  Executor executor = new Executor() {
        @Override
        public void execute(Runnable command) {
            command.run();
        }
    };*/
    Thread t1 = new Thread(new Task2(list));
    Thread t2 = new Thread(new Task(list));
    t1.start();
    t2.start();
   /* executor.execute(t1);
    executor.execute(t2);*/
}

Thank you.

DiR95
  • 49
  • 7
  • Your UI (User Interface) thread cannot be blocked. Once you do, you have around 5s on most devices to unblock, or get `ANR`ed (app not responding, and closed). What you must do, is buffer a bit of your video, then use a Handler to post from one thread to the main thread.... – Bonatti Jun 08 '16 at 12:57
  • I had a Thread.sleep(10000) between us but i have the same problem the connection with the Socket (Thread 1) don't start. – DiR95 Jun 08 '16 at 13:31
  • I have not expressed myself well.... Please, read [this (how to ask)](http://stackoverflow.com/help/how-to-ask) and [this (mcve)](http://stackoverflow.com/help/mcve) before asking, as those will help you get more and better answers from the community. Lets try this again.. [read this question on main/other threads](http://stackoverflow.com/questions/12850143/android-basics-running-code-in-the-ui-thread), then, create your Object with the buffered video. keep streaming, load a new one, then send to your main, repeat until video is over, buffer finished, or app stopped. – Bonatti Jun 08 '16 at 13:41

0 Answers0