executorservice

ThreadPoolExecutor Block When Queue Is Full?

I am trying to execute lots of tasks using a ThreadPoolExecutor. Below is a hypothetical example: def workQueue = new ArrayBlockingQueue<Runnable>(3, false) def threadPoolExecutor = new ThreadPoolExecutor(3, 3, 1L, TimeUnit.HOURS, workQueue) for(int i = 0; i < 100000; i++) threadPoolExecutor.execute(runnable) The problem is that I...

How to catch exceptions in FutureTask

After finding that FutureTask running in a Executors.newCachedThreadPool() on Java 1.6 (and from Eclipse) swallows exceptions in the Runnable.run() method, I've tried to come up with a way to catch these without adding throw/catch to all my Runnable implementations. The API suggests that overriding FutureTask.setException() should help ...

Android "misses" periodical execution of Thread using ScheduledExecutorService

Hi, I have an android app that repeatedly collects fingerprints from the wifi-networks that are around (for scientific reasons, not to invade anybodies privacy). Anyways, imagine I have a function that does this work and it's called scanWifi(). I initally wanted to start it like this: ExecutorService mExecutor = Executors.newSingle...

Consuming the results produced by an ExecutorService. Which class?

I wish I would have written the class/interface name down but I didn't... When looking through the JDK javadocs I saw reference to a class/interface with the purpose of collecting and consuming the results produced by an ExecutorService (completed Futures<T>s), possibly elsewhere in the system. At the time I took a mental note of it be...

java thread reusage via executor

Hi, I am confused on the following: To use threads in a Java program, the simplest way is to extend Thread class and implement the runnable interface (or simply implement runnable). To start the thread's execution. we must call the Thread's method start(), which in turn calls method run() of the thread. And so the thread starts. The met...

Some questions about Threading in Java

First a little background. I got a warning in NetBeans told me not to start a new thread in a constructor. I have read that the reason for that is because the new thread might start and try to reference the object started the thread before the constructor is actually done making the object. 1.) For the sake of experimentation instead...

What are the advantages of using an ExecutorService?

What is the advantage of using ExecutorService over running threads passing a Runnable into the Thread constructor? ...

a funny thing happens... ExecutorCompletionService

I have an application written in java that needs to find all the reachable hosts on the network. I use inetAddress.isReachable to do this with a timeout of 2000 milliseconds. i look up the current local machines ipaddress and based on that i attempt to reach the other ip addresses that end 1 - 255 missing out the local machines ip addr...