进程:
启动一个应用程序并入驻内存, 被操作系统视为一个进程,windows一个进程占用的内存不能大于2G, 一个线程默认分配内存为1m,所以一个进程中大概能存活2000个线程。
线程:
线程是进程的实例, 一个进程通常会产生多个线程用来处理并发操作,比如 B/S 应用,启动server应用程序,浏览器请求服务,server端都可能启动一个线程。
单例:
单例和上面的概念没有关系。 只是保证全局应用也就是一个进程中只能有一个类的实例。但是多线程访问进行写操作时,可能造成线程不安全,这个主要是实例变量造成的。
Android的单线程模型UI:
Android的UI(activity)被设计为单线程模型。而且更改
UI属性只能在UI所在的线程进行,
比如:UI异步通信若用Thread那么更改UI属性需要用Handler来处理。当然也可以直接用Handler异步通信,也可以用<!-- [if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:PunctuationKerning/>
<w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
<w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
<w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:SpaceForUL/>
<w:BalanceSingleByteDoubleByteWidth/>
<w:DoNotLeaveBackslashAlone/>
<w:ULTrailSpace/>
<w:DoNotExpandShiftReturn/>
<w:AdjustLineHeightInTable/>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:UseFELayout/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!-- [if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]--><!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
code
{mso-ansi-font-size:12.0pt;
mso-bidi-font-size:12.0pt;
font-family:宋体;
mso-ascii-font-family:宋体;
mso-fareast-font-family:宋体;
mso-hansi-font-family:宋体;
mso-bidi-font-family:宋体;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
--><!-- [if gte mso 10]>
<mce:style><!--
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
-->
<!-- [endif]-->runOnUiThread()
分享到:
相关推荐
深入浅出:讲解单例模式,多线程安全和并发访问问题.让你轻松应对面试
本资源描述了C++11 中多线程的创建,C++11中std命名空间中将boost库中的Thread加入,boost多线程从准标准变为标准,其中还介绍了C++ 多线程下的单例模式的使用,本文档为txt文档
进程服务器模型和线程服务器模型 进程服务器模型和线程服务器模型
dialog库,可以在任意类内调用,子线程或ui线程内均可显示
线程安全的单例模式 线程安全的单例模式 线程安全的单例模式
浅谈android线程模型
C++11实现线程安全的单例代码和测试代码,包含singleton.h,main.cpp,希望帮助到大家。
Xamarin.Android 非UI线程更新UI
android UI线程和后台线程交互,包括多线程之AsyncTask等例子展示。。。。。。。。。。。
Visual C++源代码 81 如何获取系统指定进程线程信息Visual C++源代码 81 如何获取系统指定进程线程信息Visual C++源代码 81 如何获取系统指定进程线程信息Visual C++源代码 81 如何获取系统指定进程线程信息Visual ...
010_android 之UI线程阻塞及其优化视频教材,讲解的比较详细,有兴趣的可以学习下哦。
泛型单例父类(带锁线程可释放),很好用的一个泛型单例父类,想将一个类变成单例类的时候,只有继承这个class就可以了;而且带线程锁,不怕多线程的时候出现错误了,而且还能手动释放;完全成品.cs文件,直接扔项目里就能用;...
关于Android中的进程和线程文档,看完后对 Android里面的Task概念有更深的了解。
史上最安全的单例,你值得拥有。
看过的最清楚的进程线程,进程和线程对比 根本不用大头书就可以理解透彻。
Java中懒汉单例设计模式线程安全测试,单例设计模式的测试
WinForm后台线程与UI线程通讯 实现进度条变化
文章地址为http://blog.csdn.net/gogogo/article/details/7009862,其中提到了如何在C++正确使用单例模式,并讲解了使用辅助类实现可以按需释放的单例模型,同时给出了多线程的模型。
Android ,非MainActivity类中的子线程和UI线程通讯,并且获取子线程传递的信息,更新UI界面。需要使用okHttp类库
进程和线程创建及其线程模型作业