Questions tagged [interrupted-exception]

210 questions
4
votes
1 answer

epoll_wait fails due to EINTR, how to remedy this?

My epoll_wait fails due to EINTR. My gdb trace shows this: enter code here 221 in ../nptl/sysdeps/pthread/createthread.c (gdb) 224 in ../nptl/sysdeps/pthread/createthread.c (gdb) [New Thread 0x40988490 (LWP 3589)] 227 in…
RajSanpui
  • 11,556
  • 32
  • 79
  • 146
4
votes
1 answer

InterruptedException not being thrown by Thread.sleep

I have a thread sleeping for some time and doing some work continuously. public void run() { while(true) { try { Thread.sleep(SOME_RANDOM_TIME); } catch (InterruptedException e) { return; } …
4
votes
4 answers

Difference between Software and Hardware Interrupts

I have recently started working on ARM Cortex Microcontrollers. While reading different articles over Internet, I usually found 2 common terms as Software Interrupt and Hardware Interrupt. What is the actual difference in both? Can you explain with…
4
votes
4 answers

Why must I wrap every Thread.sleep() call in a try/catch statement?

I am trying to write my first multi-threaded program in Java. I can't understand why we require this exception handling around the for loops. When I compile without the try/catch clauses it gives an InterruptedException. Here is the…
Sergio Gliesh
  • 329
  • 1
  • 2
  • 8
4
votes
3 answers

Thread interrupt not working (Java Android)

Edit: see here! I have a thread with the Runnable shown below. There is a problem with it which I can't figure out: half of the times I call interrupt() on the thread (to stop it) it does not actually terminate (the InterruptedException is not…
mhvis
  • 125
  • 2
  • 11
4
votes
2 answers

Need a Java based interruptible timer thread

I have a Main Program which is running a script on the target device(smart phone) and in a while loop waiting for stdout messages. However in this particular case, some of the heartbeat messages on the stdout could be spaced almost 45secs to a…
LambeauLeap
  • 285
  • 2
  • 4
  • 11
4
votes
3 answers

Interrupted exception vs isInterrupted in a while loop

Assume that I have the following code: while(!Thread.currentThread().isInterrupted()){ //do something Thread.sleep(5000); } Now Thread.sleep throws `InterruptedException so it should be like this: …
Jim
  • 18,826
  • 34
  • 135
  • 254
4
votes
3 answers

File upload form with MVC4 Web-API: Getting Error 101 (net::ERR_CONNECTION_RESET): The connection was reset. Error

I'm getting a webpage not available error when trying to access a controller action in an MVC4 Web-API app with VS2010. I am trying to upload a small sized (less than 1MB) pdf document, create a byte[] to pass on to another service. However, I…
3
votes
2 answers

Java InterruptedException - I'm confused as to what it even means for a thread to be interrupted or why it would be

I keep getting this exception inside of a synchronized block, in which I call wait on the same object I'm synchronized on. What does it mean for a thread to be interrupted first of all? secondly, what are normal scenarios where this would happen?…
Tim
  • 4,295
  • 9
  • 37
  • 49
3
votes
2 answers

ThreadPoolExecutor.shutdownNow() not throwing InterruptedException in Thread

I am implementing a Transfer Server program which takes messages from clients (via console input) and then forwards it to some sort of mailbox. To allow concurrent reception of several messages by different clients, I first created a class that…
3
votes
0 answers

Why kafka consumer don't use jdk InterruptedException when poll()?

I have noticed that KafkaConsumer advocates to use wakeup() and custom boolean to close KafkaConsumer: public class KafkaConsumerRunner implements Runnable { private final AtomicBoolean closed = new AtomicBoolean(false); private final…
3
votes
0 answers

Dealing with Future#get and InterruptedException Sonar java:S2142

In some legacy code I have inherited, there is a snippet that looks similar to this. List> callableStrings = Arrays.asList("one", "two", "three").stream() .map(s -> (Callable) () -> s) …
Quincy Bowers
  • 390
  • 2
  • 15
3
votes
1 answer

What's a good sample program to demonstrate improper handling of InterruptedException thrown by Thread.sleep()?

I've been reading around about InterruptedException, and it's immediately apparent that there's no silver bullet solution to handle it properly in all cases. What I haven't seen yet, is some sample code demonstrating what can go wrong if the…
oksayt
  • 4,333
  • 1
  • 22
  • 41
3
votes
1 answer

Spring Retryable - Async context

Have an issue with @Retryable in the Async context, I have a service call which is returning a SocketTimeOut exception. This I would have expected to retry 3 times, I do have @EnableRetry, however I am seeing something I little strange in the logs,…
aspiringCoder
  • 415
  • 1
  • 9
  • 24
3
votes
4 answers

Is this example code just facile or would there be a reason here to use interrupt()

I'm reading Goetz's Java Concurrency In Practice where this example code is shown: public final class Indexer implements Runnable { private final BlockingQueue queue; public Indexer(BlockingQueue queue) { this.queue =…
Adam
  • 5,215
  • 5
  • 51
  • 90