It’s interesting question of how different constructs perform in code. And in java world and very often encountered construct is discussion about what should be used as param (or return value) in API methods. From API maintainability, extensibility, clearness etc. point of view, answer is 101% clear. Using interfaces make APIs more generic, by leaving…
Read moreAnalyzing thread time usage
Without any testing, just seeing that it compiles, following code snippet should allow embedding periodic thread time usage analysis into application. [code lang=”java”] import java.util.HashMap; import java.util.IdentityHashMap; import java.util.Iterator; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; /** * Thread time usage analyzer */ final class Analyzer extends Thread { /** * Accuraracy of measurement; coarse timing is enough,…
Read moreAnalyzing Byte Cote
So lets see how we can test for ”param is valid type”. Bar [code lang=”java”] public class Bar { } [/code] Test [code lang=”java”] public class Test { private static final Class CLS = Bar.class; public static void test1(Object a) { if (a instanceof Bar) { int x = 0; } } public static void…
Read more