synchronization trouble

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ValValVal
    New Member
    • Oct 2008
    • 27

    synchronization trouble

    Please help me!
    I have two JFrames: ChessBoard and PawnPromotion. PawnPromotion is launched from ChessBoard, and when it is operating I call wait() on ChessPromotion. After user selects piece in PawnPromotion it calls notify() in ChessBoard and exits.

    this is the code in ChessBoard

    Code:
    PawnPromotedSelection pps=new PawnPromotedSelection(this,father_board,from);
            
            synchronized(this)
            {
           try{  this.wait();}catch (Exception e){}
             }


    This is the code in PawnPromotion when selection done.
    mc is the ChessBoard from which it was launched


    Code:
      synchronized(mc){mc.notify();}
           this.dispose();
    Unfortunately it doesn't work well.Strangely enough it works sometimes, I can't understand what conditions cause it to work,but usually it doesn't work.
    Additional information: this is part of larger program,it is not possible for me to post all the code.

    I would be very thankful for suggestions here.
    Val
  • cordeo
    New Member
    • Jul 2008
    • 16

    #2
    try{ this.wait();}ca tch (Exception e){}

    First off all: NEVER ignore exceptions, try writing
    try{ this.wait();}ca tch (Exception e){ e.printStackTra ce(); }

    and look what is happening.

    Comment

    Working...