Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Nov 02, 2015 at 06:47 PM by underdog1515 for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by underdog1515 · Nov 01, 2015 at 01:30 PM · updateprefabsthreadingglobal variablessafe

Thread safe access to global array (or list) from multiple prefabs updates

Here is the situation: I got several objects of one prefab on scene, each object is trying to communicate with one global array (or list) of points in its own Update (check if it contains some point; if it is, then generate new point; if it's not, then add this point to the end of array). I got a little mess in my head about it. I know Unity is single-threaded, that should mean updates runs sorta like this (pseudo-code):

  void MakeTheFrame()
     {
        ...
        object1.Update(); // access to global array
        // wait for completion
        object2.Update(); // access to global array
        // wait for completion
        object3.Update(); // access to global array
        // wait for completion
        ...
     }

And that means access to global array is consecutive and thread safe. Am I right on this point? And what about the same situation in Coroutine implementation? Where I can read more about things like that and how Unity code actually works inside?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
2
Best Answer

Answer by Hilfor · Nov 01, 2015 at 11:24 PM

Yes you are right. You can find more info here http://docs.unity3d.com/Manual/ExecutionOrder.html

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Nov 02, 2015 at 02:56 AM 1
Share

Right. Even coroutines run in the same thread. So at any point in time only one piece of code will execute on the main thread. Coroutines are simple "objects" which allows a coroutine scheduler to run the code in steps between yield statements. If you want to know how they work you might want to take a look at this custom coroutine scheduler implementation and this SO question

avatar image underdog1515 · Nov 02, 2015 at 06:46 PM 0
Share

@Hilfor, @Bunny83 thank you, guys!

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Just updated to 4.2.1f4... 0 Answers

Updating Pattern of Prefabs 1 Answer

Models in prefab are broken after updating .fbx file 0 Answers

change prefabs in scene? 0 Answers

Prefabs Workflow - Changing models in a 3D app after they have been used in a prefab 9 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges