队列线程黑莓 [英] Queue Thread In Blackberry

查看:158
本文介绍了队列线程黑莓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了看BB API(5.0),我无法找到连续执行批处理线程的任何方式。我知道BB对螺纹将推出的数量是有限的,所以我不想推出7如果用户点击贯穿东西速度不够快,但我无法找到像一个线程池什么。

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?

推荐答案

如果你只是想在一个单线程串行执行一串任务和顺序并不重要,你可以创建一个的Timer 对象(它有其自己的线程),那么每个任务添加到它作为一个TimerTask 。如果您使用的0或1的延迟安排,它会基本上是尽快运行任务。而且,由于一个定时器只有一个线程,如果您安排多个任务的同时,将确保只有一个会同时运行。

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.

顺便说一句,我是在黑莓开发者大会上,今年说给RIM的工程师,他说,作为OS 5.0中不再有限制了线程的数量 - 所以,这正成为越来越少的关注。

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.

这篇关于队列线程黑莓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆