# When is the product of two subgroups isomorphic to their direct product?

Let $A$ and $B$ be two subgroups of some group $G$. The product of these two subgroups is defined as $$AB = \{ab : a \in A, b \in B\},$$ while the direct product is defined as $$A \times B = \{(a,b) : a \in A, b \in B\}.$$ I know that $AB$ is a subgroup under certain conditions (e.g. $AB = BA$), but (assuming this is satisfied) are there any conditions that ensure $AB \cong A \times B$?

We need both $A\cap B=\{e\}$ and $ab=ba$ for all $a\in A$ and $b\in B$.