摘要:
JAVA笔试题:标号1-n的n个人首尾相接,1到3报数,报到3的退出,求最后一个人的标号 代码如下: public class Test { public static void main(String[] args) { System.out.println(lastPerson(13)); } 阅读全文
摘要:
基于阻塞队列实现的简单生产者消费者模式,代码如下: public class BlockingQueue_Test { private static final int MAX_CAPACITY = 10; private static ArrayBlockingQueue<Object> good 阅读全文
摘要:
通过JDK自带工具实现一个间隔并发执行的定时任务,代码如下: public class Test{ public static void main(String[] args) { ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = n 阅读全文
摘要:
编写代码,使用3个线程,1个线程打印X,一个线程打印Y,一个线程打印Z,同时执行连续打印10次"XYZ"。 本题解题采用volatile实现,主要考察的点是volatile内存可见性问题。 public class Test { private static volatile Integer Cou 阅读全文