NutzCN Logo
问答 autoloadCache里面的代码资源怎么没有释放呢
发布于 3101天前 作者 汉歌 2227 次浏览 复制 上一个帖子 下一个帖子
标签: autoloadCache
private static Ioc ioc;

public static void main(String[] args) throws ClassNotFoundException {
    ioc=
        new NutIoc(
            new ComboIocLoader("*json", "/ioc", "*anno", "com.test", "*com.jarvis.cache.aop.nutz.AutoLoadCacheIocLoader"));
    test();
    System.out.print("xxx");
    try {
        Thread.sleep(1200);
    } catch(InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    test();
    ioc.depose();

}

private static void test() {
    AutoLoadCacheService autoLoadCacheService=ioc.get(AutoLoadCacheService.class);
    AutoLoadCache data=new AutoLoadCache();
    data.setId(1);
    data.setAge(20);
    data.setName("test1");
    AutoLoadCache res1=autoLoadCacheService.getData(data);
    System.out.println("res1==" + Json.toJson(res1));
    data.setAge(30);
    data.setName("test2");
    AutoLoadCache res2=autoLoadCacheService.getData(data);
    System.out.println("res2==" + Json.toJson(res2));
}
这段代码运行后 资源没有释放,不能推出代码
3 回复

目测是有非守护线程在跑,检查一下官方代码是怎么实现的

Scanning for projects...
                                                                        
------------------------------------------------------------------------
Building AutoLoadCache-nutz 4.2
------------------------------------------------------------------------

--- exec-maven-plugin:1.2.1:exec (default-cli) @ autoload-cache-nutz ---
2016-05-28 16:03:02,915 [INFO][org.nutz.ioc.loader.annotation.AnnotationIocLoader] - Found 1 classes in 1 base-packages!
beans = ["autoLoadCacheService"]
2016-05-28 16:03:02,925 [INFO][org.nutz.ioc.loader.annotation.AnnotationIocLoader] - Found 2 classes in 1 base-packages!
beans = ["$aop_autoloadcache", "$aop_delcache"]
2016-05-28 16:03:02,926 [INFO][org.nutz.ioc.impl.NutIoc] - NutIoc init begin ...
2016-05-28 16:03:02,928 [INFO][org.nutz.ioc.impl.NutIoc] - ... NutIoc init complete
get data from DAO >test1
res1=={
   "id" :1,
   "name" :"test1",
   "age" :20
}
get data from DAO >test2
res2=={
   "id" :1,
   "name" :"test2",
   "age" :30
}
xxxres1=={
   "id" :1,
   "name" :"test1",
   "age" :20
}
res2=={
   "id" :1,
   "name" :"test2",
   "age" :30
}
2016-05-28 16:03:04,258 [INFO][org.nutz.ioc.impl.NutIoc] - org.nutz.ioc.impl.NutIoc@1920467934 is closing. startup date [16-05-28 16:03:02.927]
2016-05-28 16:03:04,265 [INFO][org.nutz.ioc.impl.NutIoc] - org.nutz.ioc.impl.NutIoc@1920467934 is deposed. startup date [16-05-28 16:03:02.927]

运行的是官方代码,没有任何修改,但是却退不出程序

添加回复
请先登陆
回到顶部