add Thread.toArrayBuffer function