Java Queue Usage addElementsToQueueInSingleThread(int numberOfElements, Queue queue, int element)

Here you can find the source of addElementsToQueueInSingleThread(int numberOfElements, Queue queue, int element)

Description

add Elements To Queue In Single Thread

License

Open Source License

Parameter

Parameter Description
numberOfElements a parameter
queue a parameter
element a parameter

Return

execution time (sec)

Declaration

public static double addElementsToQueueInSingleThread(int numberOfElements, Queue<Integer> queue, int element) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Queue;

public class Main {
    /**//from  w w  w  .j av  a  2  s.com
     *
     * @param numberOfElements
     * @param queue
     * @param element
     * @return execution time (sec)
     */
    public static double addElementsToQueueInSingleThread(int numberOfElements, Queue<Integer> queue, int element) {
        long t = System.nanoTime();
        for (int i = 0; i < numberOfElements; i++) {
            queue.add(element);
        }
        t = System.nanoTime() - t;
        return t / Math.pow(10, 9);

    }
}

Related

  1. addStringArraytoQueue(Queue set, String[] array)
  2. asString(Queue values)
  3. bQToString(Queue bQ)
  4. convertQueueToArray(Queue q)