https://jingyan.baidu.com/article/da1091fbecee3c427849d6f0.html
1 package com.sxt.thread; 2 /** 3 * 静态代理 4 * 公共接口: 5 * 1、真实角色 6 * 2、代理角色 7 * 8 * 9 * 10 */ 11 public class StaticProxy { 12 public static void main(String[] args) { 13 new WeddingCompany(new You()).happyMarry(); 14 15 //new Thread(线程对象).start(); 16 } 17 } 18 interface Marry{ 19 void happyMarry(); 20 } 21 //真实角色 22 class You implements Marry{ 23 24 @Override 25 public void happyMarry() { 26 System.out.println("you and 嫦娥终于奔月了...."); 27 } 28 29 } 30 //代理角色 31 class WeddingCompany implements Marry{ 32 //真实角色 33 private Marry target; 34 public WeddingCompany(Marry target) { 35 this.target = target; 36 } 37 @Override 38 public void happyMarry() { 39 ready(); 40 this.target.happyMarry(); 41 after(); 42 } 43 44 private void ready() { 45 System.out.println("布置猪窝。。。。"); 46 } 47 private void after() { 48 System.out.println("闹玉兔。。。。"); 49 } 50 }