Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.concurrent.LinkedBlockingQueue;
- public class Main {
- public static void main(String[]args){
- LinkedBlockingQueue<String> queue = new LinkedBlockingQueue<String>(100000);
- Producer.randomStrings(queue);
- }
- }
- import java.util.UUID;
- import java.util.concurrent.LinkedBlockingQueue;
- public class Producer implements Runnable{
- public static LinkedBlockingQueue<String> randomStrings(LinkedBlockingQueue<String> tempqueue){
- int counter = 0;
- int progress = 0;
- for(int i = 0; i<2000000; i++){
- counter++;
- String uuid = UUID.randomUUID().toString();
- try {
- tempqueue.put(uuid);
- if(counter == 1000){
- System.out.println((counter+progress)+" Strings Processed.");
- progress = progress + counter;
- counter = 0;
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- return tempqueue;
- }
- @Override
- public void run() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement