Swift analogue of Java Thread.join()
<p>That is how my code looks right now. I am trying to launch a thread but my code goes to recursive cycle. I would like to get my error reason from you or get Swift analogue of wonderful Java Thread.join() function which is very useful in this situation.</p>

<pre><code>var ret: JSON = JSON("{\"code\":\"-3\"}")
        var cont: Bool = true

    dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), {

        let req = Alamofire.request(.POST, "https://pornhub.com", parameters: parameters).validate().responseJSON { response in
            switch response.result {
            case .Success(let data):
                let json = JSON(data)
                print("TEST: " + ret.string!)
                ret = json
            case .Failure(let error):
                print("TEST: " + ret.string!)
                ret = (JSON("{\"code\":\"-2\"}"))
            }
        }

        dispatch_async(dispatch_get_main_queue(), { () -&gt; Void in

            cont = false

        })

    })

    while(cont) {
        sleep(1)
    }

    return ret
</code></pre>