Sunday, November 16, 2008

TooManyThreadsError on J2ME (BlackBerry)

Problem: J2ME(RIM's implementation) limits # of threads creation
How many threads do work simultaneousness at most ?

Solution: Thread pool
--->J2ME doesn't have the luxury of Java 5 concurrent package,

--->Doug Lea's Java 1.4 concurrent package involves too much modification to run on J2ME
http://g.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html

--->Came across O'Reilly's Java Thraeds 3rd edition
http://safari.oreilly.com/0596007825
It includes a simple version of Thread Pool for pre java 5 era.
http://java.codefetch.com/example/qm/javathreads/examples/appa/BusyFlag.java
http://java.codefetch.com/example/qm/javathreads/examples/appa/CondVar.java
http://java.codefetch.com/example/qm/javathreads/examples/appa/DaemonLock.java
http://java.codefetch.com/example/qm/javathreads/examples/appa/JobScheduler.java
http://java.codefetch.com/example/qm/javathreads/examples/appa/ThreadPool.java

Even though this is not a plug-n-play solution for J2ME, but the modification takes only couple minutes.

No comments:

Post a Comment