Skip to content

Instantly share code, notes, and snippets.

@maurociancio
Created February 11, 2015 17:48
Show Gist options
  • Save maurociancio/0d3f5a082454479490b7 to your computer and use it in GitHub Desktop.
Save maurociancio/0d3f5a082454479490b7 to your computer and use it in GitHub Desktop.

Revisions

  1. maurociancio created this gist Feb 11, 2015.
    8 changes: 8 additions & 0 deletions thread_locals.groovy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    import java.lang.reflect.*

    Thread thread = Thread.currentThread()
    Field threadLocalsField = Thread.class.getDeclaredField("threadLocals")
    threadLocalsField.setAccessible(true)
    Object threadLocalTable = threadLocalsField.get(thread)

    def values = threadLocalTable.table.grep().collect { it?.value }