标签:create ogr main 细节 desc AMM 多线程 static rip
package com.javaconcurrencyprogramming.chapter1;
/**
* @description: 模板设计模式,父类编写算法结构代码,子类实现逻辑细节。
* @author:
* @create:
**/
public class TemplateMethod {
public final void print(String message){
System.out.println("#############");
wrapPrint(message);
System.out.println("#############");
}
protected void wrapPrint(String message) {
}
public static void main(String[] args) {
TemplateMethod t1 = new TemplateMethod(){
@Override
protected void wrapPrint(String message){
System.out.println("*" + message + "*");
}
};
t1.print("Hello Thread");
TemplateMethod t2 = new TemplateMethod(){
@Override
protected void wrapPrint(String message){
System.out.println("+" + message + "+");
}
};
t2.print("Hello World");
}
}
java多线程(3)其实本节和多线程无关,简单的模板设计模式
标签:create ogr main 细节 desc AMM 多线程 static rip
原文地址:https://www.cnblogs.com/herosoft/p/10737267.html