美文网首页
Java队列分配资源小例子

Java队列分配资源小例子

作者: 春不语 | 来源:发表于2017-12-25 15:56 被阅读13次
    public class Test {
        public static void main(String[] args) {
             //add()和remove()方法在失败的时候会抛出异常(不推荐)
            Queue<String> queue = new LinkedList<String>();
            String conIds="1,2,3,4,5,6,7,8,1,2,14,58,6";
            String telIds="1,2,3,4,54,6,78,9,54,61,32,14,57,96,451";
            String[] idList = conIds.split(",");
            String[] idLists = telIds.split(",");
            for (int i = 0; i < idLists.length; i++) {
                queue.offer(idLists[i]);
            }
            for (int i = 0; i < idList.length; i++) {
                String a= queue.poll();
                System.out.println(idList[i]+"分配"+a);
                queue.offer(a);
            }
        }
    }
    

    相关文章

      网友评论

          本文标题:Java队列分配资源小例子

          本文链接:https://www.haomeiwen.com/subject/xiblgxtx.html