- 博客(0)
- 资源 (9)
- 收藏
- 关注
ios多线程开发
多线程编程指南 ................................................................................................................................................ I
简介 ................................................................................................................................................................... 1
本文档结构............................................................................................................................ 1
第一章 关于多线程编程 .......................................................................................................................... 2
1.1 什么是多线程 ............................................................................................................ 2
1.2 线程术语 .................................................................................................................... 3
1.3 多线程的替代方法 .................................................................................................... 3
1.4 线程支持 .................................................................................................................... 5
1.4.1 线程包 ............................................................................................................. 5
1.4.2 Run Loops ....................................................................................................... 6
1.4.3 同步工具 ......................................................................................................... 6
1.4.4 线程间通信 ..................................................................................................... 7
1.5 设计技巧 .................................................................................................................... 8
1.5.1 避免显式创建线程 ......................................................................................... 8
1.5.2 保持你的线程合理的忙 ................................................................................. 9
1.5.3 避免共享数据结构 ......................................................................................... 9
1.5.4 多线程和你的用户界面 ................................................................................. 9
1.5.5 了解线程退出时的行为 ............................................................................... 10
1.5.6 处理异常 ........................................................................................................ 11
1.5.7 干净地中断你的线程 .................................................................................... 11
1.5.8 线程安全的库 ................................................................................................ 11
第二章 线程管理 .................................................................................................................................... 13
2.1 线程成本 .................................................................................................................. 13
2.2 创建一个线程 .......................................................................................................... 14
2.2.1 使用NSThread.............................................................................................. 14
2.2.2 使用 POSIX的多线程 ................................................................................. 16
2.2.3 使用NSObject 来生成一个线程 ................................................................. 18
2.2.4 使用其他线程技术 ....................................................................................... 18
2.2.5 在 Cocoa程序上面使用 POSIX 线程 ......................................................... 19
2.3 配置线程属性 .......................................................................................................... 19
2.3.1 配置线程的堆栈大小 ................................................................................... 20
2.3.2 配置线程本地存储 ....................................................................................... 20
2.4 编写你线程的主体入口点 ...................................................................................... 22
2.4.1 创建一个自动释放池(Autorelease Pool) ................................................ 22
2.4.2 设置异常处理 ............................................................................................... 23
2.4.3 设置一个 Run Loop ...................................................................................... 23
2.5 中断线程 .................................................................................................................. 24
第三章 RUN LOOPS ............................................................................................................................. 26
3.1 RUN LOOP剖析 ........................................................................................................ 26
3.1.1 Run Loop 模式 ............................................................................................. 27
3.1.2 输入源 ........................................................................................................... 28
3.2 何时使用 RUN LOOP ................................................................................................ 33
3.3 使用 RUN LOOP对象 ............................................................................................... 34
3.3.1 获得 Run Loop 对象 ..................................................................................... 34
3.3.2 配置 Run Loop .............................................................................................. 34
3.3.3 启动 Run Loop .............................................................................................. 36
3.3.4 退出 Run Loop .............................................................................................. 38
3.3.5 线程安全和 Run Loop对象 ......................................................................... 38
3.4 配置 RUN LOOP 的源 ............................................................................................... 39
3.4.1 定义自定义输入源 ....................................................................................... 39
3.4.2 配置定时源 ................................................................................................... 45
3.4.3 配置基于端口的输入源 ............................................................................... 46
第四章 线程同步 .................................................................................................................................... 57
4.1 同步工具 .................................................................................................................. 57
4.1.1 原子操作 ....................................................................................................... 57
4.1.2 内存屏障和 Volatile 变量 ........................................................................... 58
4.1.3 锁 ................................................................................................................... 58
4.1.4 条件 ............................................................................................................... 59
4.1.5 执行 Selector例程 ........................................................................................ 60
4.2 同步的成本和性能 .................................................................................................. 60
4.3 线程安全和信号量 .................................................................................................. 61
4.4 线程安全设计的技巧 .............................................................................................. 62
4.4.1 完全避免同步 ............................................................................................... 62
4.4.2 了解同步的限制 ........................................................................................... 62
4.4.3 注意对代码正确性的威胁 ........................................................................... 62
4.4.4 当心死锁(Deadlocks)和活锁(Livelocks) ................................................ 64
4.4.5 正确使用Volatile变量 ................................................................................. 65
4.5 使用原子操作 .......................................................................................................... 65
4.6 使用锁 ...................................................................................................................... 67
4.6.1 使用 POSIX互斥锁 ..................................................................................... 68
4.6.2 使用NSLock 类 ............................................................................................ 68
4.6.3 使用@synchronized 指令 ............................................................................. 69
4.6.4 使用其他 Cocoa 锁 ....................................................................................... 70
4.7 使用条件 .................................................................................................................. 73
4.7.1 使用NSCondition 类 .................................................................................... 73
4.7.2 使用 POSIX条件 ......................................................................................... 74
附录 A:线程安全总结 ................................................................................................................................. 76
COCOA ................................................................................................................................. 76
基础框架(Fondation Framework)的线程安全 ........................................................ 76
Application Kit框架的线程安全 .................................................................................. 82
Core Data 框架 .............................................................................................................. 84
CORE FOUNDATION(核心框架) ...................................................................................... 84
术语表 ............................................................................................................................................................. 86
结束语 ............................................................................................................................................................. 88
推荐资源 ......................................................................................................................................................... 89
2012-01-12
Hibernate api (chm格式)
PREV NEXT FRAMES NO FRAMES
--------------------------------------------------------------------------------
Hibernate API Documentation
Hibernate API
See:
Description
Core API
org.hibernate This package defines the central Hibernate APIs.
org.hibernate.cfg This package defines APIs for configuring Hibernate, and classes for building the Hibernate configuration-time metamodel.
org.hibernate.classic This package implements backward-compatibility with Hibernate 2.1 APIs now deprecated in Hibernate3.
org.hibernate.criterion A framework for defining restriction criteria and order criteria.
org.hibernate.metadata This package defines an API for accessing the Hibernate runtime metamodel.
org.hibernate.usertype Interfaces for user-defined custom types.
Extension API
org.hibernate.action This package defines "actions" that are scheduled for asycnchronous execution by the event listeners.
org.hibernate.cache This package defines APIs and implementations for the second-level cache and query cache.
org.hibernate.cache.entry This package defines formats for disassembled state kept in the second level cache.
org.hibernate.collection This package defines a framework for collection wrappers.
org.hibernate.connection This package abstracts the mechanism for obtaining a JDBC connection.
org.hibernate.dialect This package abstracts the SQL dialect of the underlying database.
org.hibernate.dialect.function A framework for defining database-specific SQL functions that are available via the dialect.
org.hibernate.event This package defines an event framework for Hibernate.
org.hibernate.event.def This package defines a default set of event listeners that implements the default behaviors of Hibernate.
org.hibernate.id This package contains internal implementation classes for the main API interfaces.
org.hibernate.jdbc This package abstracts the mechanism for dispatching SQL statements to the database, and implements interaction with JDBC.
org.hibernate.loader This package defines functionality for processing JDBC result sets and returning complex graphs of persistent objects.
org.hibernate.loader.collection This package defines collection initializers
org.hibernate.loader.criteria This package defines the criteria query compiler and loader
org.hibernate.loader.custom This package defines a framework for custom loaders that accept handwritten SQL
org.hibernate.loader.entity This package defines entity loaders
org.hibernate.loader.hql This package defines a loader for the AST-based query parser
org.hibernate.persister A persister defines a mapping strategy for a collection or entity.
org.hibernate.persister.collection This package abstracts the persistence mechanism for collections.
org.hibernate.persister.entity This package abstracts persistence mechanisms for entities, and defines the Hibernate runtime metamodel.
org.hibernate.property This package abstracts the notion of a "property" of an entity.
org.hibernate.proxy This package defines a framework for lazy-initializing entity proxies.
org.hibernate.transaction This package abstracts the underlying transaction mechanism (JTA or JDBC) and provides strategies for obtaining application server TransactionManagers.
org.hibernate.transform Defines strategies for post-processing criteria query result sets into a form convenient to the application.
org.hibernate.tuple This package defines a runtime metamodel for entities at the object level and abstracts the differences between the various entity modes.
org.hibernate.type A Hibernate Type is a strategy for mapping a Java property type to a JDBC type or types.
Miscellaneous API
org.hibernate.jmx This package exposes a Hibernate instance via JMX.
org.hibernate.mapping This package defines the Hibernate configuration-time metamodel.
org.hibernate.stat This package exposes statistics about a running Hibernate instance to the application.
org.hibernate.tool.hbm2ddl The hbm2ddl tool.
org.hibernate.tool.instrument The instrument tool for adding field-interception hooks to persistent classes using built-time bytecode processing.
Internal Implementation
org.hibernate.engine This package contains classes that are "shared" by other packages, and implementations of some key algorithms.
org.hibernate.exception This package is a fork of Apache commons-lang nestable exceptions.
org.hibernate.hql This package defines the interface between Hibernate and the HQL query parser implementation (to allow switching between the 2.x and 3.0 HQL parsers).
org.hibernate.hql.antlr A special package for ANTLR-generated parser classes.
org.hibernate.hql.ast An ANTLR-based parser for Hibernate Query Language.
org.hibernate.hql.classic This package contains the Hibernate 2.x query parser which is being end-of-lifed.
org.hibernate.impl This package contains implementations of the central Hibernate APIs, especially the Hibernate session.
org.hibernate.intercept This package implements an interception mechanism for lazy property fetching, based on CGLIB bytecode instrumentation.
org.hibernate.lob This package defines dummy and wrapper implementations of java.sql.Clob and java.sql.Blob.
org.hibernate.pretty Classes for pretty printing things for exception and log messages.
org.hibernate.secure Declarative security for CRUD operations on entities.
org.hibernate.sql This package defines helper classes for rendering SQL fragments and SQL statements.
org.hibernate.util Utility classes.
Other Packages
org.hibernate.context
org.hibernate.hql.ast.exec
org.hibernate.hql.ast.tree
org.hibernate.hql.ast.util
org.hibernate.param
Hibernate API
This documentation concentrates upon the following Core API interfaces:
org.hibernate.Hibernate
org.hibernate.Session
org.hibernate.SessionFactory
org.hibernate.Transaction
org.hibernate.Query
org.hibernate.Criteria
org.hibernate.ScrollableResults
org.hibernate.cfg.Configuration
org.hibernate.expression.Expression
org.hibernate.expression.Order
org.hibernate.expression.Example These interfaces are fully intended to be exposed to application code.
The Extension API is intended to be used by application programmers to extend Hibernate functionality. None of these interfaces are intended to be called by the application - they are called internally by Hibernate. This API is less stable than the Core API. The safest way to extend functionality is to contribute extensions back to the project; that way extensions will be updated when the Extension API changes.
Full Hibernate documentation may be found at hibernate.org.
See Also:
Hibernate, Session, SessionFactory, Transaction, Query, Criteria, ScrollableResults, Configuration, org.hibernate.expression.Expression, org.hibernate.expression.Order, org.hibernate.expression.Example
--------------------------------------------------------------------------------
Overview Package Class Use Tree Deprecated Index Help
PREV NEXT FRAMES NO FRAMES
2010-07-25
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅