[英]What is the best way to wait until a runnable on the main thread completes in Android?
[英]What is the best way to avoid I/O operation on main thread
是否可以將I / O操作移動到外部主線程,並將結果返回到主線程?
可以使用靜態變量。
另一種可能性是ExecutorService
。 它有一個方法submit(Callable)
,你可以用它啟動Thread並返回一個Future
對象。 您可以使用它來獲取返回的Object。 Calleble<>
就像Runnable
,但它可以返回一些東西。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.