JDE4.6上奇怪的timer问题
2009-11-04 16:48
162 查看
原帖地址http://supportforums.blackberry.com/t5/Java-Development/problem-about-Timer/td-p/372342
奇怪的timer问题,timer运行的时候,上边的值怎么也传送不进去.Demo.isrun一直是初始定义的那个值.
JDE4.2下倒是正常的返回了true or false,不知道是什么原因.
import java.util.Timer; import java.util.TimerTask; import net.rim.blackberry.api.phone.phonelogs.CallLog; import net.rim.blackberry.api.phone.phonelogs.PhoneLogListener; import net.rim.blackberry.api.phone.phonelogs.PhoneLogs; import net.rim.device.api.ui.UiApplication; import net.rim.device.api.ui.component.LabelField; import net.rim.device.api.ui.container.MainScreen; public class Demo extends UiApplication { public static boolean isrun; public static void main(String[] args) { Demo theApp = new Demo(); theApp.enterEventDispatcher(); } public Demo() { pushScreen(new testscreen()); } } class testscreen extends MainScreen { public testscreen(){ super(); LabelField title = new LabelField("test",LabelField.ELLIPSIS|LabelField.USE_ALL_WIDTH); setTitle(title); final Timer time1 = new Timer(); PhoneLogListener loglisten = new PhoneLogListener(){ public void callLogAdded(CallLog cl) { System.out.println("first isrun!!!!!!!!!!!="+Demo.isrun); Demo.isrun = true; System.out.println("last isrun!!!!!!!!!!!!="+Demo.isrun); time1.scheduleAtFixedRate(new TimerMainEvent(),100,1000); } public void callLogUpdated(CallLog cl, CallLog oldCl) { System.out.println("&&&&&&&&&&&&&&&&&&&update&&&&&&&&&&&&&&&&&&"); } public void callLogRemoved(CallLog cl) { System.out.println("&&&&&&&&&&&&&&&&&&&remove&&&&&&&&&&&&&&&&&&"); } public void reset() { System.out.println("&&&&&&&&&&&&&&&&&&&reset&&&&&&&&&&&&&&&&&&"); } }; PhoneLogs.addListener(loglisten); } } class TimerMainEvent extends TimerTask { public TimerMainEvent() { } public void run() { System.out.println("run!!!!!!!!!!!!!!!!!!!!!!!!"+Demo.isrun); } }
相关文章推荐
- 奇怪的Timer Service问题。
- c++中带返回值函数没写return能通过编译但运行时会出现奇怪问题
- tomcat发现一个奇怪的问题,如我在本地tomcat发布了一个工程testProject,输入127.0.0.1:8080/testProject登录了,但是输入:本机ip地址:8080/testP
- 计蒜客 奇怪的国家问题
- 第二个窗体调用第一个窗体的Timer.Start()问题
- ol 在IE下的奇怪问题
- uclinux-2008R1.5-RC3(bf561)到VDSP5的移植(47):per_cpu的奇怪问题
- ios奇怪问题汇总
- 安装glibc时的奇怪问题(转)
- 博客园Blog程序中又一个奇怪问题
- 博客园出现了奇怪的cookie问题
- C++奇怪的问题。 有关typedef 结构体。
- freebsd 中 nohup使用时出现的奇怪问题
- java中的Timer类和线程问题
- Mvc碰到的奇怪问题
- js上层引用的一个奇怪的问题
- 简单的设置不简单:三例奇怪的无线路由器不能上网问题解决
- 调试状态下Windows Service与Timer处理事件的问题
- 关于C#中Timer定时器的重入问题解决方法(也适用于多线程)
- android bitmap篇--奇怪的问题,不知原因