企图在android上开2个webview来跑2个线程。打印线程ID后发现webview和JAVA UI确实在不同的线程。但是多个webview都在同一个线程WebViewCoreThread。
另外奇怪的是我打印处来的ID是162. ddms上的ID是11.而且UTIME很长。比MAIN线程还长。
http://stackoverflow.com/questions/10459462/using-multiple-webviews-in-android-to-simulate-the-javascript-threads/11610979#11610979
在这里也提到了:“javascript and web page layouting in all WebViews run on the same thread - WebViewCoreThread; although things may change in future Android versions.”
估计是整个android上就一个js线程。大家共享。
http://stackoverflow.com/questions/2040963/webview-threads-never-stop-webviewcorethread-cookiesyncmanager-http0-3
这里还提到:js线程WebViewCoreThread在activity关掉以后还在运行。
后来我企图用web worker解决这个问题
http://www.w3school.com.cn/html5/html_5_webworkers.asp
很遗憾,又不支持
http://html5test.com/
这个网站不错。在你的浏览器里打开就知道自己浏览器支持HTML5的状况。
考虑用rhino或v8解决
http://aisk.sinaapp.com/?p=66
http://stackoverflow.com/questions/3859305/problems-using-rhino-on-android
但是又多出多个js线程间localstorage共享的问题,而且慢
http://stackoverflow.com/questions/6880778/android-utilize-v8-without-webview
Fragment会不会好点?【试过了,也不行】
http://stackoverflow.com/questions/6880778/android-utilize-v8-without-webview
直接用V8引擎?【引擎和线程是2回事,除非自己开线程】
services怎么样?【试了一下,也是一样。而且js需要在UI线程run.】