René's URL Explorer Experiment


Title: Java Thread States — Lock During I/O Causes BLOCKED

Open Graph Title: Java Thread States — Lock During I/O Causes BLOCKED

Description: A 30-second 503? Check thread dumps for BLOCKED threads on a lock held during I/O — exactly the real production incident we decode step by step.

Open Graph Description: A 30-second 503? Check thread dumps for BLOCKED threads on a lock held during I/O — exactly the real production incident we decode step by step.

Opengraph URL: https://thecodeforge.io/java/thread-lifecycle-java/

direct link

Domain: thecodeforge.io


Hey, it has json ld scripts:
{
  "@context": "https://schema.org",
  "@type": "TechArticle",
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://thecodeforge.io/java/thread-lifecycle-java/"
  },
  "headline": "Java Thread States — Lock During I/O Causes BLOCKED",
  "description": "A 30-second 503? Check thread dumps for BLOCKED threads on a lock held during I/O — exactly the real production incident we decode step by step.",
  "keywords": "Java Thread States — Lock During I/O Causes BLOCKED, Java, Advanced, Multithreading, A 30-second 503? Check thread dumps for BLOCKED threads on a lock held during I/O — exactly the real production incident we decode step by step.",
  "proficiencyLevel": "Expert",
  "author": {
    "@type": "Person",
    "@id": "https://thecodeforge.io/about/#naren",
    "name": "Naren",
    "url": "https://thecodeforge.io/about/"
  },
  "publisher": {
    "@type": "Organization",
    "@id": "https://thecodeforge.io/#org",
    "name": "TheCodeForge",
    "url": "https://thecodeforge.io",
    "logo": {"@type": "ImageObject", "url": "https://thecodeforge.io/assets/og-image.png"}
  },
  "datePublished": "2026-03-05T00:00:00+00:00",
  "dateModified": "2026-08-30T00:00:00+00:00",
  "url": "https://thecodeforge.io/java/thread-lifecycle-java/",
  "inLanguage": "en",
  "educationalLevel": "Advanced",
  "image": "https://thecodeforge.io/assets/og-image.png",
  "isPartOf": {"@id": "https://thecodeforge.io/#website"}
}
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    {"@type": "ListItem", "position": 1, "name": "Home", "item": "https://thecodeforge.io/"},
    {"@type": "ListItem", "position": 2, "name": "Java", "item": "https://thecodeforge.io/java/"},
    {"@type": "ListItem", "position": 3, "name": "Java Thread States — Lock During I/O Causes BLOCKED", "item": "https://thecodeforge.io/java/thread-lifecycle-java/"}
  ]
}
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [
    {
      "@type": "Question",
      "name": "What is the difference between sleep() and wait() in Java threads?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "sleep() is a static method on Thread. It makes the current thread pause for a specified time, but does not release any locks it holds. It puts the thread in TIMED_WAITING state. wait() is an instance method on Object. It must be called from a synchronized context and releases the lock associated with that object. The thread goes to WAITING (or TIMED_WAITING if timeout specified) until another thread calls notify()/notifyAll() on the same object."
      }
    },
    {
      "@type": "Question",
      "name": "Why does 'jstack' show a thread as RUNNABLE when it's waiting for network I/O?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Because the thread is not blocked by a Java monitor — it's blocked at the OS level. The JVM considers it RUNNABLE because the underlying native thread is still scheduled and waiting for a system call to return. For example, java.net.SocketInputStream.socketRead0 is a native method. The OS may block the thread inside that native call, but from the JVM's perspective, the thread is still executing (RUNNABLE). This is a common source of confusion."
      }
    },
    {
      "@type": "Question",
      "name": "Can a thread move directly from RUNNABLE to TERMINATED without going through WAITING/BLOCKED?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Yes, if the thread's run() method completes without encountering any blocking operations. The thread goes from RUNNABLE (executing the body) to TERMINATED. It never enters WAITING or BLOCKED. This is typical for short-lived threads with no synchronization."
      }
    },
    {
      "@type": "Question",
      "name": "What is a spurious wakeup?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "A spurious wakeup is when a thread returns from wait() without being notified, interrupted, or timed out. The JVM specification allows this to happen (usually due to OS-level signals). This is why you must always call wait() inside a while loop that checks the condition, not an if statement."
      }
    },
    {
      "@type": "Question",
      "name": "How can I see thread states in production without killing the process?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Use jstack  (produces a text dump to stdout). Or use jcmd  Thread.print. For Kubernetes, use kubectl exec  -- jstack 1. For Java Flight Recorder (JFR), you can capture thread dumps in a recording. All are safe to run without interrupting the JVM."
      }
    }
  ]
}

og:typewebsite
og:imagehttps://thecodeforge.io/assets/og-image.png
og:image:width1200
og:image:height630

Links:

TheCodeForge https://thecodeforge.io/
Javahttps://thecodeforge.io/java/
Buy me a coffee https://ko-fi.com/thecodeforge
1Multithreading in Javahttps://thecodeforge.io/java/multithreading-java/
2Thread Lifecycle in Javahttps://thecodeforge.io/java/thread-lifecycle-java/
3Synchronization in Javahttps://thecodeforge.io/java/synchronization-java/
4Executors and Thread Pools in Javahttps://thecodeforge.io/java/executors-thread-pools-java/
5volatile Keyword in Javahttps://thecodeforge.io/java/volatile-keyword-java/
6Deadlock in Javahttps://thecodeforge.io/java/deadlock-java/
7wait notify and notifyAll in Javahttps://thecodeforge.io/java/wait-notify-notifyall-java/
8CompletableFuture in Javahttps://thecodeforge.io/java/completablefuture-java/
9Atomic Classes in Javahttps://thecodeforge.io/java/atomic-classes-java/
10CountDownLatch and CyclicBarrierhttps://thecodeforge.io/java/countdownlatch-cyclicbarrier-java/
← Back to Java track https://thecodeforge.io/java/
Homehttps://thecodeforge.io/
Javahttps://thecodeforge.io/java/
Follow https://www.linkedin.com/in/thecodeforge-io-a0676b3b5/
 ● Production Incidenthttps://thecodeforge.io/java/thread-lifecycle-java/#v2-production-incident
 🔎 Debug Guidehttps://thecodeforge.io/java/thread-lifecycle-java/#v2-debug-guide
 ⚙ Triage Commandshttps://thecodeforge.io/java/thread-lifecycle-java/#v2-triage-commands
deadlockhttps://thecodeforge.io/java/deadlock-java/
designhttps://thecodeforge.io/java/design-patterns-java/
machinehttps://thecodeforge.io/ml-ai/introduction-machine-learning/
while loophttps://thecodeforge.io/python/while-loop-python/
CompletableFuturehttps://thecodeforge.io/java/completablefuture-java/
queuehttps://thecodeforge.io/dsa/queue-data-structure/
Stackhttps://thecodeforge.io/dsa/stack-data-structure/
→Blocking I/O Inside Sync Blocks — Thread Management KillerRequests >5s, threads BLOCKED on one lock, CPU <20% → thread pool exhaustion from blocked I/O inside sync blocks. Use jshttps://thecodeforge.io/cs-fundamentals/process-thread-management/
→Java Multithreading Deadlock — Payment Batch HangPayment batch hangs after 500 transfers due to circular lock acquisition. Use consistent lock ordering and tryLock withhttps://thecodeforge.io/interview/java-multithreading-interview-questions/
→Java Deadlock — The Silent Freeze of Payment ServiceDeadlock caused gradual latency and stall: payment service's Account and Ledger locks circular wait. Automate thread dumhttps://thecodeforge.io/java/java-deadlock/
→Virtual Thread Pinning — ReentrantLock vs synchronizedProduction: 200 concurrent requests pinned virtual threads via synchronized. ReentrantLock avoids pinning. Debug with -Dhttps://thecodeforge.io/java/java-locks-reentrantlock/
→synchronized in Java — Lost Update Caused Double ChargeA missing synchronized on count++ caused 40 threads to collide, yielding duplicate IDs and double-charge complaints. Usehttps://thecodeforge.io/java/java-synchronized-keyword/
Kadane's AlgorithmIntermediatehttps://thecodeforge.io/dsa/kadanes-algorithm/
Follow https://www.linkedin.com/in/thecodeforge-io-a0676b3b5/
←PreviousMultithreading in Javahttps://thecodeforge.io/java/multithreading-java/
NextSynchronization in Java→https://thecodeforge.io/java/synchronization-java/
LinkedIn https://www.linkedin.com/in/thecodeforge-io-a0676b3b5/
Facebook https://www.facebook.com/profile.php?id=61583020033815
YouTube https://www.youtube.com/channel/UCMar7CF2EmCF1I2tw1tNVuQ
Javahttps://thecodeforge.io/java/
Pythonhttps://thecodeforge.io/python/
C / C++https://thecodeforge.io/c-cpp/
JavaScripthttps://thecodeforge.io/javascript/
DSAhttps://thecodeforge.io/dsa/
Databasehttps://thecodeforge.io/database/
System Designhttps://thecodeforge.io/system-design/
DevOpshttps://thecodeforge.io/devops/
C# / .NEThttps://thecodeforge.io/csharp/
PHPhttps://thecodeforge.io/php/
ML / AIhttps://thecodeforge.io/ml-ai/
Interviewhttps://thecodeforge.io/interview/
CS Fundamentalshttps://thecodeforge.io/cs-fundamentals/
Rusthttps://thecodeforge.io/rust/
Toolshttps://thecodeforge.io/tools/
Cheatsheetshttps://thecodeforge.io/cheatsheets/
Mobilehttps://thecodeforge.io/mobile/
Data Analyticshttps://thecodeforge.io/data-analytics/
Securityhttps://thecodeforge.io/security/
Frontendhttps://thecodeforge.io/frontend/
Data Engineeringhttps://thecodeforge.io/data-engineering/
Testinghttps://thecodeforge.io/testing/
Cloudhttps://thecodeforge.io/cloud/
Observabilityhttps://thecodeforge.io/observability/
Web Platformhttps://thecodeforge.io/web-platform/
🧯 Errors Explainedhttps://thecodeforge.io/errors/
⚒ Blueprintshttps://thecodeforge.io/blueprints/
⌨ Practicehttps://thecodeforge.io/practice/
Interview Prephttps://thecodeforge.io/interview/
DSA Problemshttps://thecodeforge.io/dsa/
Developer Toolshttps://thecodeforge.io/tools/
Cheat Sheetshttps://thecodeforge.io/cheatsheets/
Abouthttps://thecodeforge.io/about/
Sitemaphttps://thecodeforge.io/sitemap.xml
Privacyhttps://thecodeforge.io/privacy.html

Viewport: width=device-width, initial-scale=1.0

Robots: max-image-preview:large


URLs of crawlers that visited me.