Skip to content
Advertisement

Tag: multithreading

Ways to make maven build faster?

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 sometimes

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. Running on multiple thread can save out time. Note : In the example given at http://beust.com/weblog2/archives/000407.html He said :: “the

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 not an option

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 an empty Exception and pass it into Mailer: And

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 then die. AWS doesn’t use checked exceptions so I actually can’t catch SocketException directly—it must be

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()-ed and is still alive, thus is

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 InterruptedException in run(), I though I should get the message that workingThread.isInterrupted() is true, but

Advertisement