 
 public func syncprint(_ item: Any)
 {
-  let thread = NSThread.current().isMainThread ? "[main]" : "[back]"
+  let thread = Thread.current.isMainThread ? "[main]" : "[back]"
 
-  dispatch_group_async(PrintGroup, PrintQueue) {
+  printQueue.async(group: printGroup) {
     // Read silenceOutput atomically
     if OSAtomicAdd32(0, &silenceOutput) == 0
     {

import Dispatch
import Foundation.NSThread

private let PrintQueue: dispatch_queue_t = dispatch_queue_create("com.tffenterprises.syncprint", DISPATCH_QUEUE_SERIAL)
private let PrintGroup: dispatch_group_t = dispatch_group_create()

private var silenceOutput: Int32 = 0


public func syncprintwait()
{
  // Wait at most 200ms for the last messages to print out.
  let res = printGroup.wait(timeout: DispatchTime.now() + 0.2)
  if res == .timedOut
  {
    OSAtomicIncrement32Barrier(&silenceOutput)
    printGroup.notify(queue: printQueue) {
      print("Skipped output")
      OSAtomicDecrement32Barrier(&silenceOutput)
    }
