1.把主窗口的指针作为参数发给线程
2.把主窗口的指针作为参数保存在socket类中
3.使用全局变量保存主窗口的指针.more...

解决方案 »

  1.   

    class MyTheard extends Runnable
    {
    private JFrame pFrame;
       public MyTheard(JFrame parentFrame)
       {
        this.pFrame=parentFrame;
       }//下面可以对pFrame进行操作
    public void run()
    {
    }
    }在主窗口中使用MyTheard开新的线程
    MyTheard mytheard=new MyTheard(this);
      

  2.   

    线程只能通知别的线程执行某个方法,比如用notify()
      

  3.   

    class Father implemnet runnable{
         public void run(){
             Son son = new son(this);
             Thread sonThread = new Thread(son);
             Thread.start();
         }      private void refresh(){
         }  
    };class Son implement Runnable{
        private Father father;
        public Son(Father father){
            this.father = father;
        }    public void run(){
            father.refresh();    
        }
    }
      

  4.   

    Son son = new son(this);
    应为Son son = new Son(this);