小编Dmi*_*sky的帖子

ElementType.LOCAL_VARIABLE注释类型

我想创建自己的注释来注释一些局部变量.编写注释不是问题,问题是在运行时获取它们的信息.我只能从带注释的方法或方法参数中获取一些信息,但不能从局部变量中获取.有没有办法得到它?

我自己的注释是这样的:

public void m(int a)  
@MyOwnAnnotation(some information)  
int b = 5;  
}  
Run Code Online (Sandbox Code Playgroud)

或者,作为替代方案,有没有办法获取方法的代码,进一步解析它,最后得到注释值?

提前致谢.

java reflection annotations

14
推荐指数
3
解决办法
7582
查看次数

在ThreadPoolExecutor中测试PriorityBlockingQueue

我在这个例子中实现了我的ThreadPoolExecutor和PriorityBlockingQueue:https: //stackoverflow.com/a/12722648/2206775

并写了一个测试:

PriorityExecutor executorService = (PriorityExecutor)  PriorityExecutor.newFixedThreadPool(16);
    executorService.submit(new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(1000);
                Thread.sleep(1000);
                System.out.println("1");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }, 1);

    executorService.submit(new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(1000);
                Thread.sleep(1000);
                System.out.println("3");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }, 3);

    executorService.submit(new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(1000);
                Thread.sleep(1000);
                System.out.println("2");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }, 2);

    executorService.submit(new …
Run Code Online (Sandbox Code Playgroud)

java multithreading priority-queue threadpool threadpoolexecutor

4
推荐指数
1
解决办法
4046
查看次数