Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Queue Thread In Blackberry

I've looked at the BB API(5.0) and I can't find any way of serially executing a batch of threads. I know BB has a limit on the number of threads it will launch, so I don't want to launch 7 if the user clicks through things fast enough but I cannot find anything like a thread pool.

Is there an easy fix for this or do I have to create a data structure?

like image 369
Nicholas Avatar asked Nov 23 '10 08:11

Nicholas


2 Answers

If you just want to execute a bunch of tasks on a single thread serially and order isn't important, you could create a Timer object (which has its own thread) then add each task to it as a TimerTask. If you schedule it with a delay of 0 or 1, it will essentially run that task as soon as possible. And since a Timer only has a single thread, if you schedule multiple tasks concurrently, it will ensure that only one will run at a time.

Incidentally, I was talking to a RIM engineer at the BlackBerry Developer Conference this year and he said that as of OS 5.0 there are no longer limits to the number of threads -- so this is becoming less and less of a concern.

like image 92
Marc Novakowski Avatar answered Oct 21 '22 01:10

Marc Novakowski


I've tested Jeff Heaton's Thread Pool example on 4.5 and it works. (http://www.informit.com/articles/article.aspx?p=30483&seqNum=1).

like image 32
eSniff Avatar answered Oct 21 '22 02:10

eSniff