Making setFrame thread safe