Article 6KJPN Printf in multithreading context

Printf in multithreading context

by
tuxuser1
from LinuxQuestions.org on (#6KJPN)
Hi,

I'm writing a program which use multiple threads.
Now, I'd need to print for each thread some info.
Basically, each thread loads some data and I'd want to print something like:
Code:printf("Thread %d -> Data (%d/%d)", thread_num, cur_data, tot_data);Each thread should have to overwrite its own line rather than create another one.
Carriage return usage should be ok but, in this case, each thread overwrites the line
getting a non-wanted behaviour.
How could I achieve this goal ?

Regards
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments