Optimizing Bitmap Loading By Using Asynctask
Solution 1:
Adding a new answer to your completely new question :)
Depends on the amount of bitmaps. How many do you have? You don't want to create dozens of threads. After all, you only have one core on your hardware, so having multiple threads won't buy you anything - the context switching would just drown it out. If you have tons of bitmaps, you may want to have a queue of bitmaps and work through it. For that, a Thread and Handler would actually be better.
It is. Generally, I set worker threads one priority level lower than the main thread.
Solution 2:
Wait, you're calling bitmapLoaderThread.run()? It's kind of hard to figure out what's going on because these are code snippets with no context (what thread is something running on? What function?), but you don't call run() - that's the operating system's job! To start a new thread, you call start() - this will create the new thread and call its run() function. If you call run directly, you're still calling it in your own thread!
Other than that - how do you do the handshake between the two threads? How does the worker thread tell the main thread that the bitmap is loaded? You can use a Handler for that, or you can use an AsyncTask instead of the Thread altogether.
Post a Comment for "Optimizing Bitmap Loading By Using Asynctask"