What is a thread? What is the process? What are the differences and connections?

Source: Internet
Author: User
Tags gcd

Thread, which is a concrete instance of the process.

The smallest unit that the program runs, is the System independent dispatch and the CPU basic operation unit.

A process is a basic unit in the operating system that can work in parallel.

An application has a process that has at least one thread in a process.

The main difference between processes and threads is that they are different ways to manage operating system resources.

The process has a separate address space, and after a process crashes, it does not affect other processes in protected mode, and the thread is just a different execution path in a process.

Thread has its own stack and local variables, but there is no separate address space between the threads, a thread dead is equal to the entire process dead, so the multi-process program is more robust than multithreaded programs, but in the process of switching, the cost of large resources, efficiency is worse.

But for some concurrent operations that require simultaneous and shared variables, only threads can be used, and processes cannot be used


2. Talk about your understanding of multithreading development? Are there several ways to implement multithreading in iOS?

There are multiple threads in a process that co-exist, each of which performs its own task, does not interfere with one another, and a thread can create or revoke other threads.

Allow a process to perform many tasks at the same time. This reduces the wait time and improves the efficiency of the process. However, multithreading consumes resources and causes the entire process to die because one thread dies. Multithreading is also prone to security issues.

There are three kinds

First, use @synchronized (self)

Second, use GCD

Third, the use of Nsoperationqueue

3. What are the differences between thread synchronization and Asynchrony? How does multi-threaded synchronization work in iOS?

thread synchronization refers to the simultaneous operation of multiple threads or access to a resource (data). This is the time to add protection to the data, which is the thread synchronization.

Feature: Wait for resource access to end, waste time. Low efficiency, serial execution of tasks.

Thread Async: When accessing resources, while idle waiting time, while accessing other resources, implement multithreading mechanism, execute tasks in parallel.

Implementing Multi-Threaded synchronization:

Use the GCD's home column. Use Nsoperationqueue to set the maximum number of threads to 1

The serial queue in GCD is used to explain multi-threaded synchronization, that is, the task in the queue is serial. Their respective tasks are dependent, if task 1 is not completed, then Task 2 will not start, which is synchronization.


4. What are the methods for obtaining a unique identity for a device?

1.UDID

2.UUID

3.MAC ADDRESS

4.OPEN UDID

5. AD identifiers

6.Vindor identifiers

IOS7 after use is keychain (keychain)

This article is from "A long One" blog, please be sure to keep this source http://lulun426.blog.51cto.com/9197884/1565477

What is a thread? What is the process? What are the differences and connections?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.