Java – BlackBerry thread model

I've read a lot of comments and mentioned that BlackBerry threading model deviates from Java standard and may cause problems, but there is no amount of Google search that makes me mean

I've been developing a fairly large business application for BlackBerry. Although I've never had experience with Java multithreaded applications before, I haven't encountered any problems except our own

Can someone accurately describe how the BlackBerry threading model is different and what should I consider as a developer? Obviously, any link to this topic is also great

Solution

1.UI

UiApplication.getUiApplication().invokelater(new Runnable(){
  public void run(){
    myLabelField.setText("foo");
    myLabelField.setDirty(true);
  }
});

Easy?

2. Network operation should not run in UI thread Do something like this:

new Thread(){
  public void run(){
    httpconnection hc = 
            (httpconnection)Connector.open("http://www.stackoverflow.com");
  }
}.start();

These two main principles are very important You should always care about the thread you are working on

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>