Runnable with a parameter?

后端 未结 7 2464
后悔当初
后悔当初 2020-11-27 09:39

I have a need for a \"Runnable that accepts a parameter\" although I know that such runnable doesn\'t really exist.

This may point to fundamental flaw in the design

相关标签:
7条回答
  • 2020-11-27 10:39
    theView.post(new Runnable() {
        String str;
        @Override                            
        public void run() {
            par.Log(str);                              
        }
        public Runnable init(String pstr) {
            this.str=pstr;
            return(this);
        }
    }.init(str));
    

    Create init function that returns object itself and initialize parameters with it.

    0 讨论(0)
提交回复
热议问题