I have a multi module java project. Maven takes almost around 40 secs to build it. I have tried maven with multi threaded builds too by specifying -T and -C args for no of threads and cores to be used. But I haven’t seen any significant improvement in wall time of my builds. I am using maven 3.2.3 and s…
Tag: multithreading
Fast and asynchronous way of making multiple http requests in JAVA
I have a program that should make really fast http requests. Requests should be made asynchronously so that it won’t block the main thread. So I have created a queue which is observed by 10 separate threads that make http requests. If something is inserted in the queue then the first thread that gets th…
How to implemet singleThreaded=true in TestNG
In TestNG i am trying to undertand the use of singleThreaded=true attibute of @Test Annotation .I already referred http://testng.org/doc/documentation-main.html and http://beust.com/weblog2/archives/000407.html but didn’t got much help . My Question : Why do we need to execute method on single thread. R…
Java infinite loop performance
I have a Thread that only has to work when a certain circumstance comes in. Otherwise it just iterates over an empty infinite loop: Does it affect the performance when the loop actually does nothing but it has to check if it has to do the calculation every iteration? Only creating a this Thread when needed is…
Preserve Java stack trace across threads
I am using ExecutorService to send mails asynchronously, so there is a class: That handles the sending. Any exception that gets caught is logged, for (anonymized) example: Not very helpful – I need to see the stacktrace that invoked the ExecutorService that caused all of this. My solution is to create a…
Is there a way to set up two or more the event dispatch thread (EDT)?
Is Java capable of creating more than one EDT at a time? I’m experimenting with setting up EDT and how it works in updating the content of a “heavy duty” panel with potentially a dozen of panels embedded inside and with hundreds of components altogether. Currently I have I’ve looked at…
How should I handle “java.net.SocketException: Connection reset” in multithread AWS S3 file upload?
I have a ThreadPoolExecutorService to which I’m submitting runnable jobs that are uploading large (1-2 GB) files to Amazon’s S3 file system, using the AWS Java SDK. Occasionally one of my worker threads will report a java.net.SocketException with “Connection reset” as the cause and the…
What state is a sleeping thread in?
I’m looking for verification/arguments on the following: A thread is in exactly one of the 5 (+1 — 2 for WAITING) states at any point of time. Suppose a thread T calls Thread.sleep(3000); and thus puts itself into sleep for 3 secs. Which state is it in during those 3 secs? It’s clearly start…
Having Listener in new Thread
I’m trying to place my KeyListener in a new Thread called Keys in my project because my main thread is already in a loop. So I want this method to return a boolean if the key is pressed or not. I’m pretty new to Java so sorry if that is just a dumb mistake. Thread: I would appreciate an example.
Thread is interrupted by calling interrupt(), but Thread.isInterrupted() returns false
I am testing InterruptedException with the following test code: In run() , I interrupt() current working thread, and caught a InterruptedException. In main thread, my last line of code is a System.out.println(…) which prints out the interrupt status of working thread. Since I have caught InterruptedExce…