2 * Copyright (c) 2014 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
11 #include "native_client/src/include/nacl_assert.h"
14 class ClassWithInitializer {
16 ClassWithInitializer() {
17 // Sleep for 0.1 seconds. This should be long enough for both threads
18 // to enter the static initializer at the same time.
19 struct timespec time = { 0, 100000000 };
20 int rc = nanosleep(&time, NULL);
25 static void *thread_func(void *arg) {
26 static ClassWithInitializer obj;
27 printf("Initialised object %p\n", (void *) &obj);
33 int rc = pthread_create(&tid, NULL, thread_func, NULL);
38 rc = pthread_join(tid, NULL);