breautek commented on issue #1641: URL: https://github.com/apache/cordova-android/issues/1641#issuecomment-1673170885
This particular code was implemented and has been untouched for about 9 years, so way before my time... but does seem odd that `wait` is used without any `notify` or any obvious way to cancel the thread. So I guess it just simply waits for up to the timeout value and then carries on. Seems like `timeoutCheck` will only actually engage on: ```java final boolean _recreatePlugins = recreatePlugins; cordova.getActivity().runOnUiThread(new Runnable() { public void run() { if (loadUrlTimeoutValue > 0) { cordova.getThreadPool().execute(timeoutCheck); } engine.loadUrl(url, _recreatePlugins); } }); ``` Particularly if `loadUrlTimeoutValue` is greater than 0, which by default it will be. > my question is if run timeoutCheck in a specific thread and wait 20s, then user finish the webview container activity(less than 20s), memory leak will happen. because the thread is wating, and hold some resource. and this action seem waste resource(hold a thread). I want to know why do like this and What are the considerations. (if post a delay message (20s), then do the check will more good ? or any way to avoid the memory leak). I don't really understand how the thread is waiting and holding resources. From what I can understand, it will wait (regardless) for 20 seconds then it will continue. The synchronized block will cause a mutex so that only a single thread may enter the block at a time, which is probably not necessary since it's in a runnable so I don't see how multiple threads could access that function/block. The `wait(ms)` will cause the thread to wait for up to `ms` then it will continue on. I don't think that's any different than using `Thread.sleep(ms)` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org