Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Random;
- public class Z3Producer implements Runnable
- {
- public static ArrayList<String> pwdArray = new ArrayList<String>();
- public static volatile int currentSize = 0;
- public void run()
- {
- while (Zadanie3.state)
- {
- if (currentSize < 3)
- {
- if ((Math.pow(36, currentSize)) == pwdArray.size())
- currentSize++;
- String newPwd = randomString();
- if (!pwdArray.contains(newPwd))
- pwdArray.add(newPwd);
- }
- }
- }
- private static String randomString()
- {
- String alphabet = new String("1234567890qwertyuiopasdfghjklzxcvbnm");
- Random random = new Random();
- String output = new String();
- for (int i = 0; i < currentSize; i++)
- {
- output += (alphabet.charAt(random.nextInt(alphabet.length())));
- }
- return output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement