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.

View | Details | Raw Unified | Return to bug 36582
Collapse All | Expand All

(-)MutexTest.java (+48 lines)
Lines 540-543 Link Here
540
        }
540
        }
541
        
541
        
542
    } // end of State            
542
    } // end of State            
543
    
544
    public void testReaderWriterWaitReaderGo() {
545
        
546
        class Worker implements Runnable {
547
            
548
            private int state;
549
            
550
            public void run() {
551
                switch( state ) {
552
                    case 0:
553
                        synchronized ( this ) {
554
                            state = 1;
555
                            p.enterReadAccess();
556
                            RequestProcessor.getDefault().post( this );
557
                            try {
558
                                wait();
559
                            }
560
                            catch( InterruptedException e ) {
561
                                e.printStackTrace();
562
                            }
563
                            p.exitReadAccess();
564
                        }
565
                        break;
566
                    case 1:
567
                        state = 2;
568
                        RequestProcessor.getDefault().postRequest( this, 100 );
569
                        p.enterWriteAccess();
570
                        break;
571
                    case 2:
572
                        synchronized ( this ) { 
573
                            p.enterReadAccess();
574
                            state = 3;
575
                            p.exitReadAccess();
576
                            notifyAll();
577
                        }
578
                        break;
579
                }
580
            }            
581
        }
582
        
583
        Worker w = new Worker();
584
        w.run();
585
        assertEquals( "Second reader has finished", 3, w.state );
586
        
587
    }
588
    
589
    
590
    
543
}
591
}

Return to bug 36582