Blog
Thoughts on programming, systems, robotics, and everything in between, sharing what I learn and build.

Difference between wait() and sleep(), yield() in Java
The difference between wait() and sleep(), or between sleep() and yield(), is one of the oldest questions asked in Java interviews. All three pause the currently running thread, but they differ in who owns them, whether they release the lock, and how the thread wakes up again. TL;DR sleep() yield() wait() Defined in Thread Thread Object Static method? Yes Yes No Releases the lock/monitor? No No Yes Must hold the monitor (be in synchronized)? No No Yes Wakes up when timeout expires or interrupted the scheduler decides (maybe immediately) notify()/notifyAll(), timeout, or interrupt Typical use pause for a fixed time hint to give up the CPU coordination between threads JavaDoc Definition Thread Class public static void sleep(long millis[, int nanos]) throws InterruptedException
Object Initialization Order in Java
An object is a chunk of memory bundled with the code that manipulates memory. In the memory, the object maintains its state (the values of its instance variables), which can change and evolve throughout its lifetime. To get a newly-created object off to a good start, its newly-allocated memory must be initialized to a proper initial state. Here we take an in-depth look at the mechanisms Java uses to manage object initialization.
HashMap Internal Implementation Analysis in Java
HashMap is one of the most common topics in Java interviews, and “How does HashMap work?” has a deceptively simple one-line answer: “On the principle of hashing.” To say anything more, you need to know how hashing works and how HashMap applies it internally. This post assumes you already know the basics of using a HashMap; if not, start with the official Java docs. The walkthrough below uses the pre-Java-8 source as its baseline; wherever Java 8+ changed the implementation, an inline Note flags it.
WordPress $ is not defined
If you copy a normal jQuery snippet into a WordPress theme or plugin, sooner or later you hit Uncaught ReferenceError: $ is not defined. The confusing part is that jQuery itself is loaded; your other jQuery code may even be working. So why does $ blow up? Why It Happens WordPress ships its own copy of jQuery and loads it in no-conflict mode. On startup it effectively runs: jQuery.noConflict(); noConflict() tells jQuery to give back control of the global $. After it runs, jQuery still points to the library, but $ no longer does; it is left free for some other library to claim.
Getting Started with Hadoop 2.0
Apache™ Hadoop® is an open source software project that enables the distributed processing of large data sets across clusters of commodity servers. It is designed to scale up from a single server to thousands of machines, with a very high degree of fault tolerance. Rather than relying on high-end hardware, the resiliency of these clusters comes from the software’s ability to detect and handle failures at the application layer. Hadoop 1 popularized MapReduce programming for batch jobs and demonstrated the potential value of large scale, distributed processing. MapReduce, as implemented in Hadoop 1, can be I/O intensive, not suitable for interactive analysis, and constrained in support for graph, machine learning and on other memory intensive algorithms. Hadoop developers rewrote major components of the file system to produce Hadoop 2. To get started with the new version, it helps to understand the major differences between Hadoop 1 and 2.
HTTP Protocol
What’s HTTP? HTTP stands for Hypertext Transfer Protocol. It’s the network protocol used to deliver virtually all files and other data (collectively called resources) on the World Wide Web, whether they’re HTML files, image files, query results, or anything else. HTTP allows communication between a wide variety of hosts and clients, and supports a mixture of network configurations. To make this possible, it assumes very little about a particular system and keeps no state between message exchanges; this is why HTTP is called a stateless protocol. Communication usually takes place over TCP/IP sockets, though any reliable transport can be used. The standard (and default) port is 80, but a server can listen on any port.
Integrate Spring MVC with Log4j
Integrating Log4j into a Spring MVC application is quite straightforward: include the Log4j library in your project dependencies, then create a log4j.properties file to define Log4j’s appenders and put it on the project classpath. This tutorial walks through that with the Log4j 1.x logging framework. Note: This post targets Log4j 1.x, which reached end of life in August 2015 and has known vulnerabilities (e.g. CVE-2019-17571, CVE-2021-4104). Treat it as a reference for maintaining legacy projects only. For anything new, prefer SLF4J + Logback (the default in Spring Boot) or Log4j 2.x. Their configuration and API differ entirely from what’s shown here, and the official link below now redirects to Log4j 2.
How does Ajax Work
Ajax, a term coined by Jesse James Garrett that became popular after the publication of the article Ajax: A New Approach to Web Applications in February 2005, is short for Asynchronous JavaScript and XML. The normal behavior of the Internet that involves sending pages to the browser is completely changed by the use of Ajax. Ajax has become commonplace with its integration in HTML 5 and JavaScript frameworks, and in fact, the interest of developers has moved to HTML 5 for its new tags and APIs that accompany it. Among these, WebSocket appears as the successor to Ajax, because it is a superior means of communication between an application and the server or the backend.