Skip to content

Instantly share code, notes, and snippets.

View amanteaux's full-sized avatar

Aurélien Manteaux amanteaux

View GitHub Profile
@amanteaux
amanteaux / Java standard output
Created April 25, 2020 09:14
Java IO operations cannot be stopped unless they are specifically written to do so
Thread will maybe be stopped in 5 seconds... 1587805793341
Message from remote at 1587805796619: Hello from netcat
Is thread dead yet? 1587805798342
Message from remote at 1587805811746: I am still alive :)
Message from remote at 1587805818037: OK see you!
End of thread process: 1587805818939
@amanteaux
amanteaux / TimeoutTaskThreadPoolExecutor.java
Created July 16, 2017 20:54
An ExecutorService that interrupts tasks after a timeout
import java.util.Queue;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class TimeoutTaskThreadPoolExecutor {
private final Queue<Task> awaitingTasks;