multithreading - How can I know to which element a thread of my android app is related? -


First of all, I do not manually create threads.

I can monitor my thread Android app:

How can I know about the elements related to these threads?

For example, all the httpXX threads or async task # x, is there a way to find out where they were created in the code? Because they live everywhere and I feel scared of leakage of memory.

I have an image capture in the opposition, which loads pictures in threads. These threads appear in the list when I am in the scene which displays the images and when I close the app

httpX, asyncTask #X, WebViewWorkerThread, etc. When I close the app, I would like to know where I can free the memory, close connections, etc.

These threads are built by Android classes that rely internally on thread pools. The main idea of ​​the thread pool is not to create a new thread every time when you need to do something, but the threads have already started before it can be used again and keep them running, even if no work is done for them. Ho.

For example, Asinka Task # X thread is built by internal Threadpool Exchanger . If you look into this source code, you will see this threadfactory:

  Private Static Last Threadfinner sThreadFactory = New ThreadFaster () {Personal Ultimate AtomicInteger mCount = New AtomicInteger (1); Public Thread Newthread (Runnabal R) {Back to New Thread (R, "Async Task #" + MCount.et and Increment ()); }};   

WebViewCoreThread , WebViewWorkerThread , and http0 - http11 are internal workers Threads of WebView that implement all the functions of loading HTML data on the network, processing, etc. on the WebView .

So all this managed by Threads Android system and you do not need to do anything with them. And it's fine that when you close your app, they do not disappear.

Comments