# The screen is updating after while loop is completed ? need help

**URL:** https://discourse.processing.org/t/the-screen-is-updating-after-while-loop-is-completed-need-help/7119
**Category:** Beginners
**Created:** [January 2, 2019, 9:52pm UTC](https://discourse.processing.org/t/the-screen-is-updating-after-while-loop-is-completed-need-help/7119 "2019-01-02T21:52:07Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [January 3, 2019, 1:08am UTC](https://discourse.processing.org/t/the-screen-is-updating-after-while-loop-is-completed-need-help/7119/3 "2019-01-03T01:08:06Z")

</div>

here a example using a millis timer:

```auto
long startT, stopT=1000;
float ang = 0;
float colc;
color rf;

void setup() {
  size(500, 500);
  colc=random(255);
  rf=color(colc, 0, 255-colc);
}

void myTimer() {
  if ( millis() > startT + stopT ) {
    startT = millis();
    println("_next loop_");
    // what else you need to be done now?
    ang++;
    colc=random(255);
    rf=color(colc, 0, 255-colc);
  }
} 

void draw() {
  background(255, 244, 206);  
  myTimer();
  translate(width/2, height/2);
  rotate(ang *TWO_PI/60.0);
  draw_object();
}

void draw_object() {
  stroke(0, 0, 200);
  line(0, 0, 50, 50);
  fill(rf);
  rect( 50, 50, 20, 20);
}

```

---

_[View the full topic](https://discourse.processing.org/t/the-screen-is-updating-after-while-loop-is-completed-need-help/7119)._
