# About FMOD\_INIT\_THREAD\_UNSAFE

**URL:** <https://qa.fmod.com/t/about-fmod-init-thread-unsafe/19244>\
**Category:** FMOD Engine\
**Tags:** android, cpp\
**Created:** [September 6, 2022, 10:02pm UTC](https://qa.fmod.com/t/about-fmod-init-thread-unsafe/19244 "2022-09-06T22:02:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiyongman](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jiyongman](https://qa.fmod.com/u/jiyongman)\
**Post date:** [September 6, 2022, 10:02pm UTC](https://qa.fmod.com/t/about-fmod-init-thread-unsafe/19244/1 "2022-09-06T22:02:14Z")

</div>

When the Core thread safety is disabled with the `FMOD_INIT_THREAD_UNSAFE` flag and the **funcForDifferentThread()** is called “from different threads multiple times”, will the below **pseudocode** work?

```auto
class MySound {
	float curVol = 1.0f;

	MySound() {
		FMOD_System_PlaySound(TRUE);

		FMOD_Channel_SetVolume(curVol);
		FMOD_System_CreateDSPByType();
		FMOD_DSP_SetParameterFloat();
		FMOD_Channel_AddDSP();

		FMOD_Channel_SetPaused(FALSE);
	}

	~MySound() {
		FMOD_Channel_Stop();
		FMOD_DSP_Release();
	}

	bool decreaseVolume() {
		curVol -= 0.1f;

		if (curVol <= 0)
			return false;

		FMOD_Channel_SetVolume(curVol);
		
		return true;
	}
};

void funcForDifferentThread() {
	pthread_mutex_lock(&myMutex);

	MySound mySound = new MySound();

	soundList.add(mySound);

	pthread_mutex_unlock(myMutex);
}

void backgroundThreadFunc() {
	while (true) {
		pthread_mutex_lock(&myMutex);

		foreach(each in soundList) {
			if (each->decreaseVolume() == false) {
				soundList.remove(each);

				delete(each);
			}
		}

		FMOD_System_Update();

		pthread_mutex_unlock(myMutex);

		sleep(2000);
	}
}

```

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [September 12, 2022, 4:41am UTC](https://qa.fmod.com/t/about-fmod-init-thread-unsafe/19244/2 "2022-09-12T04:41:06Z")

</div>

Hi,

Yes, your pseudocode should work. As long as you are mindful of keeping calls from a single thread at a time, you should be okay. Information about thread safety can be found under [White Papers | Threads and Thread Safety](https://fmod.com/docs/2.02/api/white-papers-threads.html#fmod-core-api-thread-safety).

Hope this helps.
