Warning: To avoid potential deadlock, operations that may block, such as
networking, should be performed in a different thread than the
commandAction() handler.
Here is the way to counter this problem by using a separate thread in order to connect to the network. This ensures avoidance of deadlock situations in your application. In the run method I am calling the getConn() method which connects to the network resource. The next switchDisplayable method was a business requirement to goto the next screen.
new Thread(new Runnable() {
public void run() {
try {
getConn();
switchDisplayable(null, getWaitScreenRegRoom());
} catch (Exception e) {
}
}
}).start();
try {
getConn();
switchDisplayable(null, getWaitScreenRegRoom());
} catch (Exception e) {
}
}
}).start();
Comment with better approaches.
1 comment:
Hey,I tried with differernt thread but it runs only some advanced phone Eg E90.It hangs in ordinary phone sets. could you suggest how to solve with out threads.
Thanks,
jogi
pauljogi@gmail.com
Post a Comment