Skip to content

Instantly share code, notes, and snippets.

@stijnvanbael
stijnvanbael / Extender.java
Last active August 25, 2021 05:20
Extender extends Java objects at runtime. Any object implementing an interface can be extended this way with new methods. Or it can be used to change the behaviour of existing methods. Also useful for duck typing.
/*
Copyright (c) 2017 Stijn Van Bael.
All rights reserved.
Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
duplicated in all such forms and that any documentation,
advertising materials, and other materials related to such
distribution and use acknowledge that the software was developed
by the <organization>. The name of the
@pismy
pismy / ThreadPoolTaskExecutorWithMdcPropagation.java
Created January 12, 2016 09:15
SLF4J Tool: ThreadPoolExecutor that propagates MDC from calling thread to executor thread
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;