Tagged articles
7 articles
Page 1 of 1
Liangxu Linux
Liangxu Linux
Oct 18, 2025 · Backend Development

How to Safely Stop a Java Thread: From interrupt() to stop() and Beyond

This article explains multiple techniques for terminating a Java thread—including using interrupt flags, checking thread state with isInterrupted(), handling InterruptedException, and why the deprecated stop() method is unsafe—providing code examples, output results, and cautions about lock release and data consistency.

ExceptionJavaStop
0 likes · 12 min read
How to Safely Stop a Java Thread: From interrupt() to stop() and Beyond
Top Architect
Top Architect
May 11, 2023 · Fundamentals

How to Properly Stop a Java Thread: Methods, Examples, and Common Pitfalls

This article explains the various ways to terminate a running Java thread—including using exit flags, the deprecated stop() method, interrupt(), and exception handling—illustrates each technique with complete code examples, compares their effects on thread state, and warns about the dangers of forceful termination.

ExceptionStopinterrupt()
0 likes · 12 min read
How to Properly Stop a Java Thread: Methods, Examples, and Common Pitfalls
Top Architect
Top Architect
Aug 11, 2021 · Fundamentals

Why Thread.stop and Thread.suspend Are Deprecated and How to Gracefully Stop Threads in Java

This article explains why the Thread.stop and Thread.suspend methods were deprecated in modern Java, demonstrates the problems they cause with concrete code examples, and presents two safe alternatives—using a shared flag and the interrupt mechanism—to gracefully terminate threads without risking deadlocks or resource leaks.

DeprecatedJavaStop
0 likes · 10 min read
Why Thread.stop and Thread.suspend Are Deprecated and How to Gracefully Stop Threads in Java
Programmer DD
Programmer DD
Feb 21, 2020 · Backend Development

Mastering Thread Termination in Java: Safe Practices and Common Pitfalls

This article explains how to properly stop a Java thread, compares deprecated Thread.stop() with interruption techniques, demonstrates checking a thread's interrupted state, shows how to use exceptions and return statements for graceful termination, and warns about the dangers of forceful stops and lock release.

ExceptionJavaStop
0 likes · 12 min read
Mastering Thread Termination in Java: Safe Practices and Common Pitfalls
Selected Java Interview Questions
Selected Java Interview Questions
Dec 16, 2019 · Backend Development

How to Properly Stop a Java Thread: Methods, Examples, and Pitfalls

This article explains the various ways to terminate a running Java thread—including using exit flags, the deprecated stop() method, interrupt(), and exception handling—illustrates each approach with code samples, compares Thread.interrupted() and isInterrupted(), and discusses the dangers of forceful termination and lock release.

JavaStopThread
0 likes · 12 min read
How to Properly Stop a Java Thread: Methods, Examples, and Pitfalls