setlocale's scope in a multithreaded environment

setlocale's scope in a multithreaded environment

Post by Lars Christense » Fri, 14 Aug 1998 04:00:00



Hello everyone

I'm programming a multithreaded program and needs to control how times and
numbers are formatted. I've been using the setlocale() function from the c
library.
What is the scope of this function? Does it only apply to the current thread
or the whole process. I want to know this because i might be required to use
diffent time/number formats in each thread.

Is there a Win32 function that is more appropriate for my program?

Thanks in advance


 
 
 

1. Initialization of objects on file scope in a multithreaded environment

My question relates to using g++ in a multi-threaded environment under
Unix.

Consider a file foo.cc, having

static int x=init();
static int init() {...}
void f() {}

I.e. only f() is visible to other translation unit. According to the C++
standard (chapter 3.6.2), x will be initialized to 0 at the start of the
program, and set to whatever init() returns at some later time, but not
later as f() hast been called. Now my question: Do I have to worry about
the following scenario?

1 program starts
2 main() starts
3 several threads start
4 one thread calls f()
5 calling of init() is triggered
6 the thread is preempted
7 another thread calls f()
8 as initialization of x is not complete yet, init() is called again.

That is, could I end up with init() called twice?

Ronald
--

http://profiles.yahoo.com/ronny_fischer/

Sent via Deja.com
http://www.deja.com/

2. Application Hiding

3. ListView problem capturing 'INS' and 'DEL' keys

4. How to get OS(IE4.0, Win98) Version

5. Question: Explanation of 'oo framework' and 'oo environment' ?

6. how to obtain the Ethernet physical addr of a node

7. a good reading material on multithreaded programming in C++ environment

8. Scanners that works with Win NT 4.0

9. How to use Netmeeting in an MULTITHREADED environment?

10. lockf malfunctioning in a multithreaded environment

11. No return from usleep() in multithreaded environment

12. Using Loki::SmartPtr in multithreaded environment

13. Problem: Understanding 'using namespace' and scope resolution