# How can I get a sample of a product of two independent random variables?

I have three random variables: $X_1$, $X_2$ and $Y$ such that $X_1$ and $X_2$ are independent and $Y = X_1 \times X_2$. I think that either this question is trivial or I'm making a rookie error, but I'm not sure which.

I have samples of $X_1$ and $X_2$ as two vectors. If I multiply these vectors point-wise, does this give me a sample of $Y$? If not, how can I obtain such a sample?

I'm also interested in more general cases where $Y = f(X_1,X_2,\dots, X_n)$, for some function $f$ where samples of the $X_i$ are given.

For the sake of completeness: Let $f$ be a function of two arguments, $X_1, X_2$ be two independent random variables. Define the random variable $Y$ by $Y=f(X_1, X_2)$. Then to simulate a sample of independent realization of $Y$, simulate first independent realizations of $X_1$, then independent from that, a sample of independent realizations from $X_2$ and then use $f$ to compute $Y$. A simple example in R:
N <- 1000