V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
yaohonv
V2EX  ›  iDev

UI与其他业务线程的java code实例

  •  
  •   yaohonv · 2011-04-07 14:24:20 +08:00 · 4159 次点击
    这是一个创建于 4766 天前的主题,其中的信息可能已经有所发展或是发生改变。
    好像是第二次遇到这个网站,激动的注册了个账号,很喜欢的一种风格~新人来报道,多多指教
    最近在实践一些桌面程序,一直里不太清楚UI与业务线程的互操作问题
    1 条回复    1970-01-01 08:00:00 +08:00
    yaohonv
        1
    yaohonv  
    OP
       2011-04-07 16:29:07 +08:00
    // 定义一个带定时的线程
    final ScheduledExecutorService timer = Executors
    .newScheduledThreadPool(1);
    final Runnable beeper = new Runnable() {

    public void run() {
    if (shell.isDisposed())
    timer.shutdown();
    display.syncExec(new Runnable() {
    public void run() {
    DirectMessageParam temp = ConWeibo
    .getNearDirectMessage(weibo,
    dmp.getNearestID(), 1375764302);
    if (null != temp) {
    text1.insert(temp.getContent() + "\r\n");
    dmp = temp;
    }

    }
    });
    }
    };
    timer.scheduleAtFixedRate(beeper, 1, 5, TimeUnit.SECONDS);
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2886 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 00:26 · PVG 08:26 · LAX 17:26 · JFK 20:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.