Implementation:Ray project Ray Ray Shutdown
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Computing, Resource_Management |
| Last Updated | 2026-02-13 17:00 GMT |
Overview
Concrete tool for gracefully shutting down the Ray distributed runtime provided by the Ray Java SDK.
Description
The Ray.shutdown() static method is a synchronized method that calls runtime.shutdown() on the internal RayRuntime instance and sets the static reference to null. It disconnects from the cluster scheduler (Raylet) and Global Control Store (GCS), releases all native JNI resources, and prevents further distributed operations. The method is safe to call multiple times (idempotent).
Usage
Call Ray.shutdown() when your application is done using Ray. It is also registered as a JVM shutdown hook during Ray.init(), so it runs automatically on JVM exit if not called explicitly.
Code Reference
Source Location
- Repository: ray-project/ray
- File: java/api/src/main/java/io/ray/api/Ray.java
- Lines: L37-42
Signature
public static synchronized void shutdown()
Import
import io.ray.api.Ray;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (none) | — | — | Zero-argument method. Operates on the static Ray.runtime field. |
Outputs
| Name | Type | Description |
|---|---|---|
| Ray.runtime | null | Static field set to null after shutdown |
Usage Examples
Explicit Shutdown
import io.ray.api.Ray;
public class ShutdownExample {
public static void main(String[] args) {
Ray.init();
// ... perform distributed operations ...
// Explicit graceful shutdown
Ray.shutdown();
// Ray.runtime is now null; any further Ray calls will throw IllegalStateException
}
}