Clear Sky Science · en

Impact of virtual threads and garbage collection on energy efficiency of Java applications for battery powered IoT devices

· Back to index

Why tiny gadgets and their batteries matter

From fitness bands to wireless sensors in factories, more and more of the objects around us are really tiny computers running on tiny batteries. When those batteries die, it means cost, hassle, and electronic waste. This paper looks at a surprisingly powerful lever for making those batteries last longer: not a new chip or battery chemistry, but simply smarter software. Using a smartwatch-style device as a test case, the authors show how a modern style of Java programming can stretch battery life by roughly 40 percent without changing the hardware at all.

How everyday software can quietly waste power

Many battery-powered devices spend most of their lives waiting: waiting for a heartbeat to be read, a button to be pressed, or a message to be sent over Wi‑Fi. Traditional Java programs handle these tasks using one operating-system thread per activity and a simple "do this, then wait" style. While this is easy for programmers, it keeps the processor awake even when it has nothing useful to do, and it also triggers sudden bursts of work when Java cleans up unused memory. On a phone or laptop plugged into the wall, this mostly goes unnoticed. On a tiny watch that should run all day from a slim battery, those extra wake-ups and pauses quietly eat away at operating time.

A new way of doing many things at once

Modern versions of Java add two key tools that change this picture. The first are "virtual threads," which let the Java runtime juggle thousands of lightweight tasks on top of only a few real hardware threads. When a task is waiting for a network reply or a sensor reading, it can be parked cheaply without tying up the processor. The second is a new family of "low-latency" memory cleaners, such as ZGC, that spread their work out in tiny slices instead of stopping the whole program for long pauses. Together, these features let the chip drop into deep sleep more often and for longer stretches, which is the lowest-power state available. Instead of the device being half-awake all the time, it wakes briefly to work and then quickly returns to rest.

Figure 1
Figure 1.

A tale of two smartwatches

To see how much difference this makes in practice, the researchers built two versions of the same simple smartwatch app. Both versions periodically read heart-rate data and send it to a cloud service over Wi‑Fi, a common pattern in wearables and other Internet of Things devices. The first version used the older, blocking style of code with traditional threads and default memory cleaning. The second version used an event-driven, asynchronous style built on virtual threads and the ZGC cleaner. The hardware, battery, and workload were kept identical: an ARM Cortex‑M4 board with a Wi‑Fi module, powered by a 1000 mAh lithium‑polymer battery, running continuously for 24 hours while precise instruments recorded current draw and processor activity.

What the power measurements revealed

The legacy design behaved like an anxious person constantly pacing: the processor remained active about 85 percent of the time, even while waiting for the network, and the device could only reach a shallow sleep state. Idle current hovered around 50 milliamps, with sharp spikes above 250 milliamps during network use and memory cleanup. As a result, the battery was drained in about seven hours. By contrast, the modern design behaved more like a sprinter who works in short bursts and then rests deeply. Non-blocking network calls and timer-based wake-ups allowed the chip to spend roughly 70 percent of its time in deep sleep, with idle current near 5 milliamps and much smoother power traces. Average current fell to about 100 milliamps, and measured battery life rose to roughly ten hours—a 42 percent improvement.

Figure 2
Figure 2.

Practical lessons for greener gadgets

Beyond this single smartwatch, the study extracts general lessons for anyone building battery-powered devices. Event-driven, asynchronous designs, combined with lightweight communication methods and careful scheduling, let gadgets stay truly off between bursts of activity. Modern Java features make it easier to write such code without sacrificing safety or portability, and the tests showed that hundreds of tasks could be handled with only modest extra current draw. In other words, energy efficiency is not just about picking the right chip—it is about writing software that treats time spent sleeping as the highest form of performance. For smart cities, medical monitors, and home sensors, that mindset can translate directly into fewer battery swaps, lower costs, and less waste.

Citation: Shanjai Kumar, S., Sanjai, B.N., Etheeswar Kaarthi, S. et al. Impact of virtual threads and garbage collection on energy efficiency of Java applications for battery powered IoT devices. Sci Rep 16, 13507 (2026). https://doi.org/10.1038/s41598-026-40112-6

Keywords: IoT energy efficiency, battery life, Java virtual threads, low-power software, smartwatch devices