Skip to content

Instantly share code, notes, and snippets.

@blinker13
Last active December 20, 2015 04:04
Show Gist options
  • Select an option

  • Save blinker13/160d0dcb0678c288e814 to your computer and use it in GitHub Desktop.

Select an option

Save blinker13/160d0dcb0678c288e814 to your computer and use it in GitHub Desktop.
Small Swift 2.0 pthread example that does not work
func foo(x:UnsafeMutablePointer<Void>) -> UnsafeMutablePointer<Void> {
print("Hello World")
return nil
}
let thread:UnsafeMutablePointer<pthread_t> = nil
//
pthread_create(thread, nil, foo, nil)
pthread_join(thread.memory, nil)
@alloyapple
Copy link

func foo(x: UnsafeMutablePointer<Void>) -> UnsafeMutablePointer<Void> {
    print("Hello pthread")

    return nil
}

var pid: pthread_t = 0
pthread_create(&pid, nil, foo, nil)
pthread_join(pid, nil)

This can run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment