Skip to Content
안드로이드 멀티스레딩: 비동기 메커니즘으로 날렵하고 안정적인 앱 만들기
book

안드로이드 멀티스레딩: 비동기 메커니즘으로 날렵하고 안정적인 앱 만들기

by 한대희, 안데르스 예란손
April 2016
Beginner to intermediate
308 pages
7h 21m
Korean
Hanbit Media, Inc.
Content preview from 안드로이드 멀티스레딩: 비동기 메커니즘으로 날렵하고 안정적인 앱 만들기
152
2
-
비동기 기법
Object retainedObject
=
getLastNonConfigurationInstance
();
2
if
(
retainedObject
!
=
null
)
{
t
=
(
MyThread
)
retainedObject
;
t
.
attach
(
this
);
}
}
@
Override
public Object onRetainNonConfigurationInstance
()
{
3
if
(
t
!
=
null
&&
t
.
isAlive
())
{
return t
;
}
return null
;
}
public void onClickStartThread
(
View v
)
{
4
t
=
new MyThread
(
this
);
t
.
start
();
}
private void setText
(
final String text
)
{
runOnUiThread
(
new Runnable
()
{
@
Override
public void run
()
{
textView
.
setText
(
text
);
}
});
}
}
1
외부 클래스 참조를 피하기 위해 정적 내부 클래스로 선언된 작업자 스레드. 스레드는
Activity
인스턴스로의 참조를 포함한다.
attach
메서드는 현재 실행하는 객체에 액티비티 참조를 설정하기
위해 사용된다.
2
유지된 스레드 객체가 있으면 복구한다. 새로운
Activity ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

코드로 인프라 관리하기: 효율적인 인프라 관리를 위한 자동화 방법

코드로 인프라 관리하기: 효율적인 인프라 관리를 위한 자동화 방법

강재준

Publisher Resources

ISBN: 9788968481703