Android – Prevent white screen at startup

As we all know, many Android apps display a white screen very briefly before their first Activity comes into focus. This problem is observed in the following cases: Android apps that extend the …

Java – Multi-threaded crawler with ExecutorService

I’m working to make a crawler in Java. I made a single-threaded crawler to visit a single page and fetch all links on that page. Now I want to make it multi-threaded but facing difficulties. In the …

Java Chat Multi-Client Receiving thread

In a lot of multclient java programs people use a separate thread which only receives the messages from the server. Is it really necessary? Why can’t it be done in the main thread? What should be the …

Fast and asynchronous way of making multiple http requests in JAVA

I have a program that should make really fast http requests. Requests should be made asynchronously so that it won’t block the main thread. So I have created a queue which is observed by 10 separate …

Thread is interrupted by calling interrupt(), but Thread.isInterrupted() returns false

I am testing InterruptedException with the following test code: Runnable runMe = new Runnable() { @Override public void run() { for(int i=0; i<6; i++) { System.out....

Spring dynamically choosing between data sources (alternative to ThreadLocal)

I’ve read about AbstractRoutingDataSource and the standard ways to bind a datasource dynamically in this article: public class CustomerRoutingDataSource extends AbstractRoutingDataSource { @…

TCP threaded server/client

I’m trying to make a threaded TCP server that accept multiple client. It’s only accepting one client. Any idea on how to make the server accepting multiple client? Here is what I tried so far: I …

Run Handler messages in a background thread

I want to run some Runnable in a background thread. I want to use Handler because it’s convenient for delays. What I mean is handler.post(runnable, delay); Where runnable should be run in background …

Tips to prevent deadlocks in java

I am studying java threads and deadlocks, I understand deadlock’s examples but I wonder if there are general rules to follow to prevent it. My question is if there are rules or tips that can be …

Java Thread Sleep and Interrupted Exception

Why does a sleep thread need a try catch to catch Interrupted Exception? Why does a sleep even emit an Interrupted Exception error? This are the two questions I really wanna find out about in java …