# Threading 1.3: Success Story

**URL:** <https://discourse.julialang.org/t/threading-1-3-success-story/27111>\
**Category:** Internals & Design\
**Created:** [August 2, 2019, 1:16pm UTC](https://discourse.julialang.org/t/threading-1-3-success-story/27111 "2019-08-02T13:16:20Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tobias.knopp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobias.knopp/32/7551_2.png) [@tobias.knopp](https://discourse.julialang.org/u/tobias.knopp)\
**Post date:** [August 2, 2019, 1:32pm UTC](https://discourse.julialang.org/t/threading-1-3-success-story/27111/2 "2019-08-02T13:32:29Z")

</div>

To answer the question myself, the following runs the UI updating code on the main thread again:

```julia
using Gtk.ShortNames

b = Box(:v)
win = Window(b,"test")

button = Button("do work")
push!(b,button)

pb = ProgressBar()
push!(b,pb)

Gtk.showall(win)

function doWork()
  N = 20
  for k=1:N
    Gtk.GLib.g_idle_add(nothing) do user_data
      set_gtk_property!(pb,:fraction,(k-1)/(N-1) )
      Cint(false)
    end
    sum(collect(1:100000000)) # some heavy work
  end
end

signal_connect(button, "clicked") do widget
  Threads.@spawn doWork()
end

```

---

_[View the full topic](https://discourse.julialang.org/t/threading-1-3-success-story/27111)._
