Extended Basics 17

Learn how to do code review

Extended Basics 17

Post by dacker123 on Sat Dec 21, 2013 4:38 am
([msg=78547]see Extended Basics 17[/msg])

Code: Select all
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExtBasic14 {

        private final ExecutorService executorService = Executors.newFixedThreadPool(100);
        private static final int MAX = 1337;
        private int timeToGetLeet = 0;

        ExtBasic14() throws InterruptedException {
                for (int i = 0; i <= MAX; i++) {                                    // here
                        executorService.execute(new Runnable() {
                                public void run() {
                                        incrementLeetness();
                                }
                        });
                }
                executorService.shutdown();
                while (!executorService.isTerminated()) {
                        Thread.sleep(500);
                }
                System.out.println(timeToGetLeet);
        }

        private void incrementLeetness() {
                int obfusticatedIncremental = timeToGetLeet;
                obfusticatedIncremental = obfusticatedIncremental + 1;
                timeToGetLeet = obfusticatedIncremental;
        }

        /**
         * @param args
         */
        public static void main(String[] args) throws InterruptedException {
                new ExtBasic14();
        }

}

I modified the code so that it prints 1337. Now what?

-- Sat Dec 21, 2013 4:12 pm --

Ow crap it doesnt always work. :(
Sorry.
dacker123
New User
New User
 
Posts: 2
Joined: Tue Oct 30, 2012 1:22 am
Blog: View Blog (0)


Return to Extended Basics

Who is online

Users browsing this forum: No registered users and 0 guests