multithreading - TOO MANY THREADS ERROR EXCEPTION -
While making an application for Blackberry, I have a problem with 7 thread calls, each of which downloads audio to each audio. Server and it works fine, but when I start my application twice an exception exception has occurred, "many errors error exceptions", then tell me how I can solve this problem.
I use single thread instead of starting 7 threads 1. Creating a TaskWorker class
TaskWorker implementing the public class Runnable {Personal Boolean left = false; Personal vector queue = new vector (); Public Taskwalker () {New thread (this). Start (); } Private work getNext () {Job Task = Zero; If (! Queue.isEmpty ()) {task = (function) queue.first element (); } Return work; } Run the public null () (while leaving) {Job work = Friendly (if); if (task! = Null) {task.doTask (); queue.removeElementAt (function);} and {// task is zero and only The reason is that no other work in the vector has been synchronized (queue) {try {queue.wait (}}} hold (interrupted e) e.printStackTrace ();}}}}} Public Zero addTask (function Work} {synchronize (queue) {if (quote) {queue.addElement (function); queue.notify ();}}} public left blank () {synchronize (queue) {quit = true;
2 Create an abstract work square
Public abstract class works {abstract} doctask ();}
Now create the task. The public class extends the DownloadTask function {zero doTask ()} {// something to do}}
> Taskwalker Task Worker = New Taskwalker (TaskWorker.addTask) (New DownloadTask);