Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved JOBS and Multithreading

Discussion in 'C# Job System' started by Ne0mega, Aug 28, 2023.

  1. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    702
    I am using a AStar Project, that relies on multithreading.
    I am now finding I pretty much am going to need to get into multithreading. ... or jobs.

    Can I run multithreading on AStar and jobs on everything else, or is it globally one or the other for the project?
     
  2. Enderlook

    Enderlook

    Joined:
    Dec 4, 2018
    Posts:
    44
    Unity Jobs and System.Threading (multithreading) are two different technologies with a somehow similar output: allowing to run code in parallel.
    The difference is that Unity Jobs uses the same thread pool that Unity uses for its own tasks, rather than a separated one, this reduces context switch between threads. Also, Unity Jobs includes a dependency system to avoid any kind of deadlock.
    You can use both approaches in the same project, preferring one over the other in different parts of the project. Nothing forces you to choose one globally over the other.
     
    Last edited: Sep 7, 2023
    Ne0mega likes this.