# RunByRef<T>(ref T, int)

> Performs the job's Execute method immediately on the same thread.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Jobs](/engine/6000.3/script-reference/unity/jobs.md)
* **Assembly:** UnityEngine.CoreModule

## RunByRef\<T>(T, int)

```csharp
public static void RunByRef<T>(this ref T jobData, int arrayLength) where T : struct, IJobFor
```

### Parameters

**** (T): The job and data to execute.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): This job's Execute method will be called this many times, with its index argument ranging from 0 to (arrayLength - 1). Typically, this corresponds to the length of an array or array-like container passed in the job struct, but this is not necessarily the case.

### Remarks

This variant passes the job struct by reference instead of by value, which can be faster than [IJobForExtensions.Run](/engine/6000.3/script-reference/unity/jobs/ijobforextensions/run.md) for larger job structs. Note that worker threads always operate on a local copy of the job struct.

While this method is useful in development or test environments, it is typically a mistake to use it in production; it offers no real benefits over implementing the job code as a simple main-thread function call. To schedule a job to run asynchronously, use [IJobForExtensions.ScheduleByRef](/engine/6000.3/script-reference/unity/jobs/ijobforextensions/schedulebyref.md).

Additional Resources: [IJobFor](/engine/6000.3/script-reference/unity/jobs/ijobfor.md).
