Monday, July 4, 2011

Inter-thread communication methods between UI thread and worker threads - 1

Introduction

There are lots of requirements of Smart phone application developers these day. And one of key technology for the beginner level of smart phone developer is  how can he make UI faster. It's because usually CPUs of smart phones are slower than Desktops, if we write code that does not only UI update but also every other things such as managing database or network connectivity, the UI responses very slow. In order to avoid this problem, we should make worker threads that do everything except UI updates so that the main thread may focus on only UI update jobs.

Inter-thread communication between UI thread and worker threads


Most of UI application programmers know that UI updates should be done in one thread(usually the main thread and some people call it UI thread) and create child threads doing other works. One of most important things in separate UI thread and worker thread is the communication method between threads. Because we usually create our worker threads with our own run loop, we easily take care of mutual exclusions among threads and easily communicate among them by using of our own task queue or pipe or any other lots of ways. But we usually don't make the run loop of the main thread (UI thread), we should use the inter-thread communication methods that the UI framework provides and to use these methods, we should know how to deal it and what to be concerned.

Implementation of "result of the task" signal has system dependency because the run-loop of UI thread is usually provided by UI framework

1 comment:

  1. This posting is not finished yet. I think it will be a longer posting than I originally expected. There are lots of thing to describe about inter-thread communication between UI thread and worker threads.
    When I finish this, the entire posting will be separated into two or three :)

    ReplyDelete