Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I add arguments to run() method in java?

How can I add input arguments to run method in java threading?

@Override
public void run(int a, String b){
    // do something
}
// The method run(int) of type particle_explode must override or implement a supertype methodJava(67109498)

If I add argument, it said The method run(int) of type particle_explode must override or implement a supertype methodJava(67109498)

So how can I add argument to it?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Put the values to the Runnable and have the Thread run that.

Runnable r = new MyRunnable(a, b);

new Thread(r).run();

If you need a convenient way to run a variety stuff in the background, submit() runnable things to an Executor.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading