---
title: "SubFlow"
description: "This page lists the Java SDK names for SubFlows."
canonical_url: "https://docs.superdurable.io/zh-Hans/reference/java/subflow/"
source: "docs/reference/java/subflow.mdx"
locale: "zh-Hans"
---

# SubFlow

This page lists the Java SDK names for [SubFlows](https://docs.superdurable.io/zh-Hans/concepts/primitives/subflow.md).
The doc comment of each API gives its parameters, defaults, and errors. Read
them in the [Java SDK API reference](https://docs.superdurable.io/zh-Hans/reference/java.md#api-reference).

<a id="api-names"></a>

## API names

| Task                                                 | Java API                                                                      | Dex behavior                                                                                                     |
| ---------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| Start a child Flow and wait for it                   | **SubFlow\.run** in **waitFor**                                               | [SubFlows](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#subflows)                       |
| Set the child timeout, Attributes, and configuration | **SubFlowOptions**                                                            | [SubFlowOptions](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#subflow-options)          |
| Choose what happens to an existing child             | **reusePolicy** of **SubFlowOptions.Builder**, with **SubFlowReusePolicy**    | [SubFlowReusePolicy](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#subflow-reuse-policy) |
| Read the child result                                | **SubFlow\.getConditionResults** in **execute**. It returns a **FlowResult**. | [SubFlow results](https://docs.superdurable.io/zh-Hans/reference/java/waits.md#subflow-results)                  |
| Read the generated child Flow ID                     | **SubFlow\.getFlowId**                                                        | [SubFlowReusePolicy](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#subflow-reuse-policy) |
| Stop a child that lost an **AnyOf**                  | **Client.stopFlow** with the child Flow ID                                    | [Stop a Flow](https://docs.superdurable.io/zh-Hans/reference/server/runtime-client.md#stop-a-flow)               |

<a id="step-types-that-start-subflows"></a>

## Step types that start SubFlows

The generated child Flow ID is **SubFlow:{parent Flow ID}-{Step execution ID}-{index}**.
The Step execution ID starts with the Step type. A Step whose Step type contains **-**
cannot start SubFlows, because the dash would make the child Flow ID ambiguous. When
**waitFor** of such a Step returns a **SubFlow\.run** condition, the Worker sends the
result and logs a warning. The server rejects the result as an invalid Worker response
and fails the attempt without retry. With the default failure policy, the Flow fails.
Steps that start no SubFlows may keep a dash in their Step type. To start SubFlows from
the Step, rename its Step type, for example by overriding **getStepType**.

Changed in 1.45: a Step whose Step type contains **-** can no longer start SubFlows.

<a id="example"></a>

## Example

Example: [examples/java/src/main/java/io/superdurable/dex/primitives/subflow/SubFlowParentFlow.java](https://github.com/superdurable/dex/tree/main/examples/java/src/main/java/io/superdurable/dex/primitives/subflow/SubFlowParentFlow.java)
