A digital clock in a thread

My code goes here - Threading a clock in Ruby. - Pastebin.com

I’m new to threading and also new to animations.

I’m trying to run a thread that prints out the time in (H:M:S) format.

Can you look at it and say something about it?
I want the clock to run on it’s own part of the screen without
interfering with my “what’s your name?” thing.

When I run the code this is what happens (and let’s think, for now I
type my name as “lol”)

Current time - 12:27:31
What’s your name?
Current time - 12:27:39ol #“ol” when i typed “lol”
lol is a nice name
Current time - 12:28:55

And yes, I’m new to “\r” carriage return too.

I’m not sure, but perhaps curses would help you to put things at exact
places on the screen.

Abinoam Jr.

Curses would be a good approach, but you haven’t really defined what you
want your interaction to be like?

It’s not a good approach, but another way would be to just wrap the
stream
calls in a mutex.

Something like this: http://pastebin.com/58aFQBPx

I didn’t actually test that, but if you are just trying to learn
threading,
it should help out.

I want the clock to run on the first line of the shell
And when I’m typing my name in when it’s asking, I want the clock to
just
stay where it is and not clone itself on the second line.

The output of your code is same to mine.
When it prints out “What’s your name?”
The current time clones itself and prints its value after “whats your
name?” has been asked. Which is what I’m trying to avoid.

Thanks, will check it out.