Reputation: 1280
I build an application which re-colors pixels from Bitmaps without shadering, only with the CPU pixel by pixel. It's fast enough for me, but I'm wondering if the CPU is using multi-threading by default without actually using it in programming?
Upvotes: 3
Views: 850
Reputation: 2219
From Documentation:
By default, your application launches a thread of execution (called "main"). This thread is very important because it is in charge of dispatching events to the appropriate user interface widgets, including drawing events. It is also the thread in which your application interacts with components from the Android UI toolkit (components from the android.widget and android.view packages). As such, the main thread is also sometimes called the UI thread.
And a Thread's relation to CPU is (multithreading example):
This advantage of a multithreaded program allows it to operate faster on computer systems that have multiple or multi-core CPUs, or across a cluster of machines, because the threads of the program naturally lend themselves to truly concurrent execution. In such cases, the programmer must be careful to avoid race conditions and other non-intuitive behaviors. In order for data to be correctly manipulated, threads will often need to rendezvous in time in order to process the data in the correct order. Threads may also require mutually exclusive operations (often implemented using semaphores) in order to prevent common data from being simultaneously modified or read while in the process of being modified. Careless use of such primitives can lead to deadlocks.
Another use of multithreading, applicable even for single-CPU systems, is the ability for an application to remain responsive to input. In a single-threaded program, if the main execution thread blocks on a long-running task, the entire application can appear to freeze. By moving such long-running tasks to a worker thread that runs concurrently with the main execution thread, it is possible for the application to remain responsive to user input while executing tasks in the background. On the other hand, in most cases multithreading is not the only way to keep a program responsive, with non-blocking I/O and/or Unix signals being available for gaining similar results.
Long story made short. No, your program would not be multithreading unless you specifically told it to. And in Android's case AsyncTask would be the route to go when interacting with the UIThread (main).
Upvotes: 4