# How to pass parameters into a thread function

**URL:** <https://discourse.processing.org/t/how-to-pass-parameters-into-a-thread-function/27204>\
**Category:** Beginners\
**Created:** [January 19, 2021, 5:06pm UTC](https://discourse.processing.org/t/how-to-pass-parameters-into-a-thread-function/27204 "2021-01-19T17:06:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [January 19, 2021, 5:06pm UTC](https://discourse.processing.org/t/how-to-pass-parameters-into-a-thread-function/27204/1 "2021-01-19T17:06:32Z")

</div>

Hi!  
I recently came across the function `thread`. However when I tried to use the function

```auto
void setup() {thread("timer");}
void draw() {background(frameCount % 255);}

void timer(int delay, int rep) {
  for(int i = 0; i < rep || rep == -1; i++) {
    println(i,millis());
    delay(delay);
  }
}

```

it says that the function  
`timer()() does not exist `  
So is there a way to do something like `thread("timer(500,-1)")`?

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [January 19, 2021, 8:51pm UTC](https://discourse.processing.org/t/how-to-pass-parameters-into-a-thread-function/27204/2 "2021-01-19T20:51:16Z")

</div>

See

> [@Passing a parameter through a thread](https://discourse.processing.org/t/passing-a-parameter-through-a-thread/21498):
>
> Hi again everyone, currently stuck on a problem, I wish to create multiple threads to maximize cpu usage as I understand processing only uses the one thread by default, (perhaps this is java by default). I have done some research and converted a piece of code I found to work in processing. class A implements Runnable { String to\_print; int t; A(String to\_print) { this.to\_print = to\_print; } A(Integer t) { this.t = t; } //public void run() { // System.out.println(to\_p…
