Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.BitSet;
- import java.util.concurrent.Semaphore;
- public class Main {
- private static final int THREADS = 1;
- public static Semaphore semaphore = new Semaphore(1);
- public static BitSet set;
- public static int size;
- public Main(int x) {
- size = x + 1;
- set = new BitSet(size);
- set.flip(2, size);
- }
- public static void main(String[] args) throws InterruptedException {
- Main bitSetSieveMain = new Main(60);
- Thread [] threadsTab = new Thread[THREADS];
- for(int i=0; i<threadsTab.length; i++) threadsTab[i] = new Thread(new Sito(i));
- long start = System.nanoTime();
- for(int i=0; i<threadsTab.length; i++)
- {
- threadsTab[i].start();
- }
- for(int i=0; i<threadsTab.length; i++)
- {
- threadsTab[i].join();
- }
- long time = System.nanoTime() - start;
- System.out.println(time + " nano seconds to perform " + set.length() + " numbers " + bitSetSieveMain);
- }
- public String toString() {
- return set.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment