You can’t, b/c its signature is parameterless & void
.
Instead, you can create a class
which extends
Thread:
Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Thread.html
/**
* Threaded Method (v1.0.1)
* GoToLoop (2019/Jan/)
*
* https://Discourse.Processing.org/t/
* how-can-i-use-thread-with-functions-that-has-inputs/12964/2
*/
void setup() {
noLoop();
}
void draw() {
background((color) random(#000000));
}
void mousePressed() {
new ThreadedMethodWithIntParameter((int) random(100));
}
class ThreadedMethodWithIntParameter extends Thread {
final int input;
ThreadedMethodWithIntParameter(final int inp) {
input = inp;
start();
}
@Override void run() {
println(input);
}
}