我怎样才能在安排黑莓特定线程 [英] How can I schedule a particular thread in Blackberry

查看:119
本文介绍了我怎样才能在安排黑莓特定线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

欲自动调度一个线程与特定的时间间隔。我还需要在后台continously没有挂起的设备执行这一点。

I want to auto-schedule a thread with a particular time interval. I also need to execute this in the background continously without hangs to the device.

我与应用程序管理器类试过,但它是应用程序的调度,我需要在应用程序内调度线程。

I have tried this with Application Manager Class but it's for application scheduling and I need to schedule thread within the application.

推荐答案

我会用的 TimerTask的

public class MyScreen extends MainScreen {
    private Timer mTimer;
    public MyScreen() {        
        mTimer = new Timer();
        //start after 1 second, repeat every 5 second
        mTimer.schedule(mTimerTask, 0, 5000);
    }

    TimerTask mTimerTask = new TimerTask() {
        public void run() {
            // some processing here
        }
    };
}

看<一个href=\"http://supportforums.blackberry.com/t5/BlackBerry-Developer-s-Blog/BlackBerry-API-Hidden-Gems-Part-Two/ba-p/309237\">BlackBerry API隐藏的宝石(第二部分)

这篇关于我怎样才能在安排黑莓特定线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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