Java

Please catch Throwable in a task submitted to a thread pool

Exceptions thrown in a task submitted to a thread pool will just disappear. You won’t even see the log. You can catch java.lang.Exception and handle it. But to make things even better, please catch java.lang.Throwable instead. In theory, it’s not recommended to catch a Throwable. But to be pragmatic, it’s important for you to see …

Please catch Throwable in a task submitted to a thread pool Read More »

Condition variable related code is hard to understand. So let me explain

There are a few strange things about Condition related code in Java concurrency. I’ll use the following code to show you. The code is about one cup and two threads. One thread is trying to fill it, the other to drink from it. The code uses explicit Lock + Condition API. But what I’m going …

Condition variable related code is hard to understand. So let me explain Read More »

Make sure chromedriver can run with Java selenium code, both in a real machine and in docker

Install chromedriver You want to make the following line of code run successfully. In windows, you need to download chrome driver from https://chromedriver.chromium.org/downloads and put it in system’s path (An alternative is to set the executable file’s path as a system property “webdriver.chrome.driver”, not beautiful) In *nix or linux-based Docker, you can Options needed for …

Make sure chromedriver can run with Java selenium code, both in a real machine and in docker Read More »