Skip to content

Month: September 2015

parallel counting in Java using AtomicInteger

[java]
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.TimeUnit;

class ParallelCounterExample {
public static void main(String[] args) throws InterruptedException {
int threads = 2000;
ExecutorService executor = Executors.newFixedThreadPool(threads);
final AtomicInteger atomi = new AtomicInteger();
for(int i=0; i<threads; i++) {
executor.execute( new Runnable() {
@Override
public void run() {
atomi.getAndIncrement();
}
});
}
executor.awaitTermination(1, TimeUnit.SECONDS);
executor.shutdown();
System.out.println(atomi.get());
}
}
[/java]

Some of the photos from the supermoon total lunar eclipse yesterday. The next will be on November 25, 2034.
🌞🌎🌛
#moon #supermoon #bloodmoon #lunareclipse #perigee-syzygy #perigee #bloodmooneclipse #lua #penumbra #umbra #RayleighScattering.
Instagram: http://ift.tt/1FDqVtl

#supermoon #moon #eclipse.
Instagram: http://ift.tt/1LWkVJ8

#supermoon #moon #eclipse #virginia #usa 🌞🌎🌙.
Instagram: http://ift.tt/1KEvL8G

#supermoon #moon #eclipse 🌞🌎🌙.
Instagram: http://ift.tt/1VkFNP8

Supermoon eclipse! I’m so happy that despite the weather we are able to see it.
🌞🌎🌙.
Instagram: http://ift.tt/1KZkhOH

cleaned up, new filters, brushes… and googly eyes! #pimpmyroomba.
Instagram: http://ift.tt/1KDLLbf

My first time in a drive-in theater..
Instagram: http://ift.tt/1jnmIjy