LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-13-2024, 11:08 PM   #16
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,924
Blog Entries: 1

Rep: Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886Reputation: 1886

You can synchronize your threads' access to a FILE with flockfile/funlockfile.
Code:
FILE *ftty= stdout;
flockfile(ftty);
fprintf(ftty, "\x1b[%d;%dH", row, column);
fprintf(ftty, "Doing great");
fprintf(ftty, "\x1b[K");
fflush(ftty);
funlockfile(ftty);
Note: it doesn't mean additional complexity, flockfile+funlockfile is already being used by FILE-operations; also nesting flockfile's isn't a problem, there is a counter to properly handle that.

Last edited by NevemTeve; 06-14-2024 at 03:11 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] printf $"Hello $var\n" vs. printf "Hello $var\n" -- not a typo. What is it? GrapefruiTgirl Programming 2 10-21-2010 08:21 AM
Multithreading is possible in linux ?. Which tool used for this? saira Linux - Software 1 03-24-2004 10:29 PM
How OpenMozix is used for multithreading in cluster computing in linux sabeen Red Hat 1 03-24-2004 10:25 PM
multithreading libraries Pres Programming 3 06-20-2003 03:27 AM
How is 'man 3 printf' different from 'man printf' ?? purpleburple Linux - General 3 09-23-2002 12:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration