NO1:
For an application, the real entrance is in the Activitythread class, and the Activitythread contains the Main method that we are familiar with. Activitythread is a final class and cannot be inherited. When the zygote process hatches a new application process, the monkey executes the Activitythread Main method, and the main method does some general logic, such as preparing Looper and message queues , It then calls Activitythread's Attach method to bind it to activitymanagerservice, starting to continuously read messages in the message queue and distribute the message.
No2:
Public Abstract classfactory{/*** Abstract Factory method * Specific production what subclass to achieve*/ Public Abstract<textendsProduct> T createproduct (class<t>clz);} Public classConcretefactoryextendsfactory{@Override Public<textendsProduct> T createproduct (class<t>CLZ) {Product P=NULL; Try{p=(Product) class.forname (clz.getname). newinstance (); }Catch(Exception e) {e.printstacktrace (); } return(T) p; }} Public classclient{ Public Static voidMain (string[] args) {Factory Factory=Newconcretefactory (); Product P= Factory.createproduct (CONCRETEPRODUCTB.class); P.method (); }}
No3:
Cons: Each time we add a new product to the factory method pattern, we need to write a new product class , and also introduce the abstraction Layer , which inevitably leads to the complexity of the class structure.
"Android Source design mode"--factory method mode