This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 258400 - Deadlock not detected
Summary: Deadlock not detected
Status: RESOLVED FIXED
Alias: None
Product: debugger
Classification: Unclassified
Component: Code (show other bugs)
Version: 8.1
Hardware: PC Windows 10
: P3 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-16 15:46 UTC by kirilv
Modified: 2016-05-22 01:40 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kirilv 2016-03-16 15:46:11 UTC
Product Version = NetBeans IDE 8.1 (Build 201510222201)
Operating System = Windows 10 version 10.0 running on amd64
Java; VM; Vendor = 1.8.0_73
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.73-b02

Reproducibility: Happens every time

STEPS:
 Run the following program in Debug mode and press Debug -> Check for Deadlock.
 This is a Deadlock, but it doesn't detect one.

public class ThreadLocalExample {
    
    private static Thread thread1;
    private static Thread thread2;
    
    public static class MyRunnable implements Runnable {

        private final ThreadLocal<Integer> threadLocal = new ThreadLocal<>();
                
        @Override
        public void run() {
            String name = Thread.currentThread().getName();
            System.out.println("RUNNING: " + name);
            int v = (int) (Math.random() * 100D);
            threadLocal.set(v);
            System.out.println("SETTING TO '" + name + "' = " + v);
            try {
                if(name.equals("T1")) {
                    System.out.println("WAITING FOR T2 TO COMPLETE...");
                    thread2.join();
                } else {
                    System.out.println("WAITING FOR T1 TO COMPLETE...");
                    thread1.join();
                }
                Thread.sleep(2000);
            } catch (InterruptedException e) {
            }
            System.out.println("ENDING " + name + " " + threadLocal.get());
        }
    }   
   
    public static void main(String[] args) throws InterruptedException {
        MyRunnable sharedRunnableInstance = new MyRunnable();

        thread1 = new Thread(sharedRunnableInstance, "T1");
        thread2 = new Thread(sharedRunnableInstance, "T2");

        thread1.start();
        thread2.start();
    }
}



ACTUAL:
 No  Deadlock Detected

EXPECTED:
  Deadlock Detecte
Comment 1 Martin Entlicher 2016-05-20 15:12:17 UTC
Fixed by changeset:   297345:e09b98cc6446
http://hg.netbeans.org/core-main/rev/e09b98cc6446
Comment 2 Quality Engineering 2016-05-22 01:40:56 UTC
Integrated into 'main-silver', will be available in build *201605220002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/e09b98cc6446
User: mentlicher@netbeans.org
Log: #258400: Deadlock caused by waiting for Thread.join() is detected.