Android beginner's brother a few minor problems, we hope to help
Multithreading: 1 with Thread with Runnbale can achieve multi-threaded, why should HandlerThread Run method 2.HandlerThread why can not override 3 msg sent to Handler's intentions, there is nothing directly in the Runnable's run method in solving bad?
About Database 4 How to query the database exists? (Returns a Boolean value, there is also not new) We open the database with SQLiteHelper.getDatabase (), this method if your database exists, it is opened, if not exist, create one, I want to check whether there is enough, there does not exist, do not create one.
Thank you. Reply: Reply: What no one is willing to help me Reply: 3 msg sent to Handler's intentions, there is nothing directly in the Runnable's run method in solving bad? run method is not the main thread can not update the UI, otherwise see, handmessage in the main thread Reply: HandlerThread is what is right handler Reply:
Directly with the Handle, then the thread is the main thread, single Handle does not really multi-threaded. Even if it has to load Runnable, it is still the main thread, to achieve multi-threaded, starting HandleThread, detailed look at Mars video. There are talked about. Reply: We are using the thread pool to achieve multi-threaded Reply: 1. HandlerThread is used under Android environment, and Runnble not the same, they are different JVM. 2 Because the parent class defines HandlerThread run () method can not be overridden, ah, this is basic knowledge of java Oh, and Android does not matter. 3 You do not understand the difference between Handler and run () action, Handler equivalent measures to deal with after the trigger event, and the run is a method that must be performed for each thread, while the timing of their execution are not the same, Handler will at some time way After the execution, and run is executed immediately without waiting for the occurrence of any event.
Reply: The third answer is better upstairs! ! Reply: A lot of things on the official document has explained why the question in a more meaningful place, such discussions more meaningful Reply:
1 HandlerThread is used under Android environment, and Runnble not the same, they are different JVM. 2 Because the parent class defines HandlerThread run () method can not be overridden, ah, this is basic knowledge of java Oh, and Android does not matter. 3 You do not understand the difference between Handler and run () action, Handler equivalent measures to deal with after the trigger event, and the run is a method that must be performed for each thread, while the timing of their execution are not the same, Handler will at some time way After the execution, and run is executed immediately without waiting for the occurrence of any event.
Well, the answer, quite justified, why not the way to my fourth question to answer Reply:
1. HandlerThread is used under Android environment, and Runnble not the same, they are different JVM. 2 Because the parent class defines HandlerThread run () method can not be overridden, ah, this is basic knowledge of java Oh, and Android does not matter. 3 You do not understand the difference between Handler and run () action, Handler equivalent measures to deal with after the trigger event, and the run is a method that must be performed for each thread, while the timing of their execution are not the same, Handler will at some time way After the execution, and run is executed immediately without waiting for the occurrence of any event.
Well, the answer, quite justified, why not the way to my fourth question to answer
No comments:
Post a Comment