groovy为jdk增加了很多扩展方法,让我们更加方便的使用,这里我们就来实现一下自己的扩展方法。首先我们先看一下groovy的扩展方法是如何实现的。
groovy中我们可以这样使用
Thread.start {
println "start"
}
public static Thread start(Thread self, Closure closure) {
return createThread(null, false, closure);
}
private static Thread createThread(String name, boolean daemon, Closure closure) {
Thread thr