Runnable with a parameter?

后端 未结 7 2523
后悔当初
后悔当初 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:31

    I would first want to know what you are trying to accomplish here to need an argument to be passed to new Runnable() or to run(). The usual way should be to have a Runnable object which passes data(str) to its threads by setting member variables before starting. The run() method then uses these member variable values to do execute someFunc()

提交回复
热议问题