C++11 多线程:数据保护

C++11 多线程:数据保护

转自:http://www.oschina.net/question/12_59878


编写多线程程序时,多个线程同时访问某个共享资源,会导致同步的问题,这篇文章中我们将介绍 C++11 多线程编程中的数据保护。

数据丢失

让我们从一个简单的例子开始,请看如下代码:

01#include <iostream>
02#include <string>
03#include <thread>
04#include <vector>
05 
06using std::thread;
07using std::vector;
08using std::cout;
09using std::endl;
10 
11class Incrementer
12{
13    private:
14        int counter;
15 
16    public:
17        Incrementer() : counter{0} { };
18 
19        void operator()()
20        {
21            for(int i = 0; i < 100000; i++)
22            {
23                this->counter++;
24            }
25        }
26 
27        int getCounter() const
28        {
29            return this->counter;
30        }      
31};
32 
33int main()
34{
35    // Create the threads which will each do some counting
36    vector<thread> threads;
37 
38    Incrementer counter;
39 
40    threads.push_back(thread(std::ref(counter)));
41    threads.push_back(thread(std::ref(counter)));
42    threads.push_back(thread(std::ref(counter)));
43 
44    for(auto &t : threads)
45    {
46        t.join();
47    }
48 
49    cout << counter.getCounter() << endl;
50 
51    return 0;
52}

这个程序的目的就是数数,数到30万,因此创建了三个线程,使用一个共享变量 counter,每个线程负责给这个变量增加10万计数。

这段代码创建了一个名为 Incrementer 的类,该类包含一个私有变量 counter,其构造器非常简单,只是将 counter 设置为 0.

紧接着是一个操作符重载,这意味着这个类的每个实例都是被当作一个简单函数来调用的。一般我们调用类的某个方法时会这样 object.fooMethod(),但现在你实际上是直接调用了对象,如 object(). 因为我们是在操作符重载函数中将整个对象传递给了线程类。最后是一个 getCounter 方法,返回 counter 变量的值。

再下来是程序的入口函数 main(),我们创建了三个线程,不过只创建了一个 Incrementer 类的实例,然后将这个实例传递给三个线程,注意这里使用了 std::ref ,这相当于是传递了实例的引用对象,而不是对象的拷贝。

现在让我们来看看程序执行的结果,使用 GCC 4.7 或者更新版本,或者是 Clang 3.1 来进行编译,编译方法:

1g++ -std=c++11 -lpthread -o threading_example main.cpp

运行结果:

01[lucas@lucas-desktop src]$ ./threading_example
02218141
03[lucas@lucas-desktop src]$ ./threading_example
04208079
05[lucas@lucas-desktop src]$ ./threading_example
06100000
07[lucas@lucas-desktop src]$ ./threading_example
08202426
09[lucas@lucas-desktop src]$ ./threading_example
10172209

但等等,不对啊,程序并没有数数到30万,有一次居然只数到10万,为什么会这样呢?好吧,加1操作对应实际的处理器指令其实包括:

1movl    counter(%rip), %eax
2addl    $1, %eax
3movl    %eax, counter(%rip)

首个指令将装载 counter 的值到 %eax 寄存器,紧接着寄存器的值增1,然后将寄存器的值移给内存中 counter 所在的地址。

我听到你在嘀咕:这不错,可为什么会导致数数错误的问题呢?嗯,还记得我们以前说过线程会共享处理器,因为只有单核。因此在某些点上,一个线程会依照指令执行完成,但在很多情况下,操作系统会对线程说:时间结束了,到后面排队再来,然后另外一个线程开始执行,当下一个线程开始执行时,它会从被暂停的那个位置开始执行。所以你猜会发生什么事,当前线程正准备执行寄存器加1操作时,系统把处理器交给另外一个线程?

我真的不知道会发生什么事,可能我们在准备加1时,另外一个线程进来了,重新将 counter 值加载到寄存器等多种情况的产生。谁也不知道到底发生了什么。

正确的做法

解决方案就是要求同一个时间内只允许一个线程访问共享变量。这个可通过 std::mutex 类来解决。当线程进入时,加锁、执行操作,然后释放锁。其他线程想要访问这个共享资源必须等待锁释放。

互斥(mutex) 是操作系统确保锁和解锁操作是不可分割的。这意味着线程在对互斥量进行锁和解锁的操作是不会被中断的。当线程对互斥量进行锁或者解锁时,该操作会在操作系统切换线程前完成。

而最好的事情是,当你试图对互斥量进行加锁操作时,其他的线程已经锁住了该互斥量,那你就必须等待直到其释放。操作系统会跟踪哪个线程正在等待哪个互斥量,被堵塞的线程会进入 "blocked on m" 状态,意味着操作系统不会给这个堵塞的线程任何处理器时间,直到互斥量解锁,因此也不会浪费 CPU 的循环。如果有多个线程处于等待状态,哪个线程最先获得资源取决于操作系统本身,一般像 Windows 和 Linux 系统使用的是 FIFO 策略,在实时操作系统中则是基于优先级的。

现在让我们对上面的代码进行改进:

01#include <iostream>
02#include <string>
03#include <thread>
04#include <vector>
05#include <mutex>
06 
07using std::thread;
08using std::vector;
09using std::cout;
10using std::endl;
11using std::mutex;
12 
13class Incrementer
14{
15    private:
16        int counter;
17        mutex m;
18 
19    public:
20        Incrementer() : counter{0} { };
21 
22        void operator()()
23        {
24            for(int i = 0; i < 100000; i++)
25            {
26                this->m.lock();
27                this->counter++;
28                this->m.unlock();
29            }
30        }
31 
32        int getCounter() const
33        {
34            return this->counter;
35        }  
36};
37 
38int main()
39{
40    // Create the threads which will each do some counting
41    vector<thread> threads;
42 
43    Incrementer counter;
44 
45    threads.push_back(thread(std::ref(counter)));
46    threads.push_back(thread(std::ref(counter)));
47    threads.push_back(thread(std::ref(counter)));
48 
49    for(auto &t : threads)
50    {
51        t.join();
52    }
53 
54    cout << counter.getCounter() << endl;
55 
56    return 0;
57}

注意代码上的变化:我们引入了 mutex 头文件,增加了一个 m 的成员,类型是 mutex,在 operator()() 中我们锁住互斥量 m 然后对 counter 进行加1操作,然后释放互斥量。

再次执行上述程序,结果如下:

1[lucas@lucas-desktop src]$ ./threading_example
2300000
3[lucas@lucas-desktop src]$ ./threading_example
4300000

这下数对了。不过在计算机科学中,没有免费的午餐,使用互斥量会降低程序的性能,但这总比一个错误的程序要强吧。

防范异常

当对变量进行加1操作时,是可能会发生异常的,当然在我们这个例子中发生异常的机会微乎其微,但是在一些复杂系统中是极有可能的。上面的代码并不是异常安全的,当异常发生时,程序已经结束了,可是互斥量还是处于锁的状态。

为了确保互斥量在异常发生的情况下也能被解锁,我们需要使用如下代码:

01for(int i = 0; i < 100000; i++)
02 {
03 this->m.lock();
04 try
05 {
06     this->counter++;
07     this->m.unlock();
08 }
09 catch(...)
10 {
11     this->m.unlock();
12     throw;
13 }
14 }

但是,这代码太多了,而只是为了对互斥量进行加锁和解锁。没关系,我知道你很懒,因此推荐个更简单的单行代码解决方法,就是使用 std::lock_guard 类。这个类在创建时就锁定了 mutex 对象,然后在结束时释放。

继续修改代码:

01void operator()()
02{
03    for(int i = 0; i < 100000; i++)
04    {
05    lock_guard<mutex> lock(this->m);
06 
07    // The lock has been created now, and immediatly locks the mutex
08    this->counter++;
09 
10    // This is the end of the for-loop scope, and the lock will be
11    // destroyed, and in the destructor of the lock, it will
12    // unlock the mutex
13    }
14}

上面代码已然是异常安全了,因为当异常发生时,将会调用 lock 对象的析构函数,然后自动进行互斥量的解锁。

记住,请使用放下代码模板来编写:

01void long_function()
02{
03    // some long code
04 
05    // Just a pair of curly braces
06    {
07    // Temp scope, create lock
08    lock_guard<mutex> lock(this->m);
09 
10    // do some stuff
11 
12    // Close the scope, so the guard will unlock the mutex
13    }
14}


  •                     <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#csdnc-thumbsup"></use>
                        </svg><span class="name">点赞</span>
                        <span class="count"></span>
                        </a></li>
                        <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true">
                            <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-csdnc-Collection-G"></use>
                        </svg><span class="name">收藏</span></a></li>
                        <li class="tool-item tool-active is-share"><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;1582594662_002&quot;}"><svg class="icon" aria-hidden="true">
                            <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-csdnc-fenxiang"></use>
                        </svg>分享</a></li>
                        <!--打赏开始-->
                                                <!--打赏结束-->
                                                <li class="tool-item tool-more">
                            <a>
                            <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
                            </a>
                            <ul class="more-box">
                                <li class="item"><a class="article-report">文章举报</a></li>
                            </ul>
                        </li>
                                            </ul>
                </div>
                            </div>
            <div class="person-messagebox">
                <div class="left-message"><a href="https://blog.csdn.net/fjb2080">
                    <img src="https://profile.csdnimg.cn/0/C/6/3_fjb2080" class="avatar_pic" username="fjb2080">
                                            <img src="https://g.csdnimg.cn/static/user-reg-year/1x/10.png" class="user-years">
                                    </a></div>
                <div class="middle-message">
                                        <div class="title"><span class="tit"><a href="https://blog.csdn.net/fjb2080" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">fjb2080</a></span>
                                            </div>
                    <div class="text"><span>发布了202 篇原创文章</span> · <span>获赞 122</span> · <span>访问量 150万+</span></div>
                </div>
                                <div class="right-message">
                                            <a href="https://bbs.csdn.net/topics/395527245" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-messageboard">他的留言板
                        </a>
                                                            <a class="btn btn-sm  bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">关注</a>
                                    </div>
                            </div>
                    </div>
    </article>
    
<script>
$("#blog_detail_zk_collection").click(function(){
    window.csdn.articleCollection()
})
        <div id="dmp_ad_58"><div id="kp_box_58" data-pid="58"><script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

        <a id="commentBox" name="commentBox"></a>
还能输入1000个字符
<div class="comment-list-container">
	<a id="comments"></a>
	<div class="comment-list-box">
	</div>
	<div id="commentPage" class="pagination-box d-none"></div>
	<div class="opt-box text-center">
		<div class="btn btn-sm btn-link-blue" id="btnMoreComment"></div>
	</div>
</div>
<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_59" data-pid="59"><script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

多线程共享数据保护

12-18

请教下多线程问题,如标题“多线程共享数据保护”。也看了以前一些朋友提的问题,以及回复。感觉还没有找到正确答案,所有再拿出来提下。 问题的提出:需求是通讯后的数据保存,我采用2个线程一个负责通讯,一个负 论坛

线程池 将任务push_back到list中的问题

06-02

最近在用到线程池,于是在codeproject上找到一个(http://www.codeproject.com/KB/threads/win32threadpool.aspx) 用这个线程池有一个问题 论坛

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_60" data-pid="60"><script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

C++应用多线程提高并发性

12-19

请大家谈谈你在项目应用多线程来提高并发性的场景? 有哪些好的技巧? 在什么情况下应用多线程? 有什么好的建议? 论坛

C++多线程编程视频教程(C++11多线程并发)

03-06

C++多线程编程视频教程(C++11多线程并发) 第一节什么是多线程? 第二节多线程API详解(一) 第三节多线程API详解(二) 第四节多线程API详解(三) 第五节多线程模拟火车站售票 第六节多线 论坛

		<div class="recommend-item-box blog-expert-recommend-box" style="display: block;">
		<div class="d-flex">
			<div class="blog-expert-recommend">
				<div class="blog-expert">
					<div class="blog-expert-flexbox" data-report-view="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><a href="https://blog.csdn.net/fuyajun01" target="_blank"><img src="https://profile.csdnimg.cn/1/C/F/3_fuyajun01" username="fuyajun01" alt="山庄来客" title="山庄来客"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="fuyajun01" data-nick="山庄来客">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><a href="https://blog.csdn.net/fuyajun01" target="_blank"><h5 class="oneline" title="山庄来客">山庄来客</h5></a></span>  <p></p><p class="article-num" title="224篇文章"> 224篇文章</p><p class="article-num" title="排名:5000+"> 排名:5000+</p><p></p></div></div></div><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><a href="https://blog.csdn.net/chenm91" target="_blank"><img src="https://profile.csdnimg.cn/0/D/E/3_chenm91" username="chenm91" alt="chenm91" title="chenm91"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="chenm91" data-nick="chenm91">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><a href="https://blog.csdn.net/chenm91" target="_blank"><h5 class="oneline" title="chenm91">chenm91</h5></a></span>  <p></p><p class="article-num" title="7篇文章"> 7篇文章</p><p class="article-num" title="排名:千里之外"> 排名:千里之外</p><p></p></div></div></div><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><a href="https://blog.csdn.net/daoming1112" target="_blank"><img src="https://profile.csdnimg.cn/7/E/0/3_daoming1112" username="daoming1112" alt="苦逼的IT男" title="苦逼的IT男"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="daoming1112" data-nick="苦逼的IT男">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><a href="https://blog.csdn.net/daoming1112" target="_blank"><h5 class="oneline" title="苦逼的IT男">苦逼的IT男</h5></a></span>  <p></p><p class="article-num" title="165篇文章"> 165篇文章</p><p class="article-num" title="排名:千里之外"> 排名:千里之外</p><p></p></div></div></div><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><a href="https://blog.csdn.net/u013630349" target="_blank"><img src="https://profile.csdnimg.cn/6/C/0/3_u013630349" username="u013630349" alt="稚枭天卓" title="稚枭天卓"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="u013630349" data-nick="稚枭天卓">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/7714543&quot;}"><a href="https://blog.csdn.net/u013630349" target="_blank"><h5 class="oneline" title="稚枭天卓">稚枭天卓</h5></a></span>  <p></p><p class="article-num" title="597篇文章"> 597篇文章</p><p class="article-num" title="排名:953"> 排名:953</p><p></p></div></div></div></div>
				</div>
			</div>
		</div>
	</div>
<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_61" data-pid="61"><script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

多线程访问数据库时应该怎么进行临界区保护呢?

01-06

用的是一个全局的ConnectionPtr和一个全局的RecordsetPtr 在主线程中建立了与数据库的连接 工作线程中对数据库进行读写的操作 对数据库的操作是做在函数中的,然后工作线程调用这些函数 论坛

<div class="recommend-item-box  recommend-download-box clearfix">
	<a href="https://download.csdn.net/download/xxl194627/4018745" rel="noopener" target="_blank" data-report-click="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;index&quot;:&quot;17&quot;,&quot;strategy&quot;:&quot;BlogCommendFromBaidu&quot;,&quot;dest&quot;:&quot;https:\/\/download.csdn.net\/download\/xxl194627\/4018745&quot;}" data-report-view="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;index&quot;:&quot;17&quot;,&quot;strategy&quot;:&quot;BlogCommendFromBaidu&quot;,&quot;dest&quot;:&quot;https:\/\/download.csdn.net\/download\/xxl194627\/4018745&quot;}" data-report-query="depth_1-utm_source=distribute.pc_relevant.none-task&amp;utm_source=distribute.pc_relevant.none-task">
		<div class="content clearfix">
			<div class="">
				<h4 class="text-truncate oneline clearfix">
					05.多线程数据保护(安全队列2					</h4>
				<span class="data float-right">01-13</span>
			</div>
			<div class="desc oneline">
					05.多线程数据保护(安全队列2				</div>
			<span class="type-show type-show-download">下载</span>
		</div>
	</a>
</div>
<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_62" data-pid="62"><script type="text/javascript">
    (function() {
        var s = "_" + Math.random().toString(36).slice(2);
        document.write('<div style="" id="' + s + '"></div>');
        (window.slotbydup = window.slotbydup || []).push({
            id: "u3501897",
            container: s
        });
    })();

类vector类型的成员在线程中push_back报错

11-24

// 代码: int SyncTcpServer::start() { if (stopRunning) return 0; listenThread = ::CreateThread(NULL, 论坛

130 个相见恨晚的超实用网站,一次性分享出来

03-09 阅读数 36万+

相见恨晚的超实用网站持续更新中。。。 博文 来自: 爪白白的个人博客

                <div class="recommend-item-box type_hot_word">
                <div class="content clearfix" style="width: 712px;">
                    <div class="float-left">
                                                                            <span>
                            <a href="https://blog.csdn.net/yilovexing/article/details/80577510" target="_blank">
                            python</a>
                        </span>
                                                    <span>
                            <a href="https://blog.csdn.net/slwbcsdn/article/details/53458352" target="_blank">
                            json</a>
                        </span>
                                                    <span>
                            <a href="https://blog.csdn.net/csdnnews/article/details/83753246" target="_blank">
                            java</a>
                        </span>
                                                    <span>
                            <a href="https://blog.csdn.net/qq_35077512/article/details/88952519" target="_blank">
                            mysql</a>
                        </span>
                                                    <span>
                            <a href="https://blog.csdn.net/pdcfighting/article/details/80297499" target="_blank">
                            pycharm</a>
                        </span>
                                                    <span>
                            <a href="https://blog.csdn.net/sinyu890807/article/details/97142065" target="_blank">
                            android</a>
                        </span>
                                                    <span>
                            <a href="https://blog.csdn.net/gexiaoyizhimei/article/details/100122368" target="_blank">
                            linux</a>
                        </span>
                                                    <span>
                            <a href="https://download.csdn.net/download/xhg_gszs/10978826" target="_blank">
                            json格式</a>
                        </span>
                                                
                                                                            <span>
                            <a href="https://www.csdn.net/gather_11/MtTaMgxsLWRvd25sb2Fk.html" target="_blank">
                            c# 与matlab</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_19/MtTaMgzsLWRvd25sb2Fk.html" target="_blank">
                            c# xml缩进</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_10/MtTaMg0sLWRvd25sb2Fk.html" target="_blank">
                            c#传感器基础</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_14/MtTaMg2sLWRvd25sb2Fk.html" target="_blank">
                            c#操作wps</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_13/MtTaMg3sLWRvd25sb2Fk.html" target="_blank">
                            c# md5使用方法</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_10/MtTaMg4sLWRvd25sb2Fk.html" target="_blank">
                            c# 引用父窗口的组件</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_11/MtTaQgwsLWRvd25sb2Fk.html" target="_blank">
                            c#报错不实现接口成员</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_1a/MtTaQgysLWRvd25sb2Fk.html" target="_blank">
                            c# char utf8</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_19/MtTaQgzsLWRvd25sb2Fk.html" target="_blank">
                            c#内嵌python</a>
                        </span>
                                                    <span>
                            <a href="https://www.csdn.net/gather_10/MtTaQg0sLWRvd25sb2Fk.html" target="_blank">
                            希尔排序c#</a>
                        </span>
                                                                        </div>
                </div>
                </div>
                                <div class="recommend-loading-box">
                <img src="https://csdnimg.cn/release/phoenix/images/feedLoading.gif">
            </div>
            <div class="recommend-end-box">
                <p class="text-center">没有更多推荐了,<a href="https://blog.csdn.net/" class="c-blue c-blue-hover c-blue-focus">返回首页</a></p>
            </div>
        </div>
                        <div class="template-box">
                <span>©️2019 CSDN</span><span class="point"></span>
            <span>皮肤主题: 大白</span>
            <span> 设计师:
                                        CSDN官方博客                                    </span>
            </div>
                </main>
    <aside class="blog_container_aside">
<!--主页引入-->

<div id="asideProfile" class="aside-box">
<!-- <h3 class="aside-title">个人资料</h3> -->
<div class="profile-intro d-flex">
    <div class="avatar-box d-flex justify-content-center flex-column">
        <a href="https://blog.csdn.net/fjb2080" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080&quot;}">
            <img src="https://profile.csdnimg.cn/0/C/6/3_fjb2080" class="avatar_pic" username="fjb2080">
                                <img src="https://g.csdnimg.cn/static/user-reg-year/1x/10.png" class="user-years">
                        </a>
                </div>
    <div class="user-info d-flex flex-column profile-intro-name-box">
        <div>
                            <span class="name csdn-tracking-statistics tracking-click " data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080&quot;}" username="fjb2080">
                <a href="https://blog.csdn.net/fjb2080" class="" id="uid" title="fjb2080">
                fjb2080                    </a>
            </span>
        </div>
        <div class="profile-intro-name-boxFooter">
                                            <span class="personal-home-page" style="right:-96px;"><a target="_blank" href="https://me.csdn.net/fjb2080">TA的个人主页 &gt;</a></span>
                        </div>
    </div>
</div>
<div class="data-info d-flex item-tiling">
            <dl class="text-center" title="202">
                        <dt><a href="https://blog.csdn.net/fjb2080" data-report-query="t=1">原创</a></dt>
            <dd><a href="https://blog.csdn.net/fjb2080" data-report-query="t=1"><span class="count">202</span></a></dd>
                </dl>
    <dl class="text-center" id="fanBox" title="404">
        <dt>粉丝</dt>
        <dd><span class="count" id="fan">404</span></dd>
    </dl>
    <dl class="text-center" title="122">
        <dt>获赞</dt>
        <dd><span class="count">122</span></dd>
    </dl>
    <dl class="text-center" title="233">
        <dt>评论</dt>
        <dd><span class="count">233</span></dd>
    </dl>
    <dl class="text-center" title="1509556">
        <dt>访问</dt>
        <dd><span class="count">150万+</span></dd>
    </dl>
</div>
<div class="grade-box clearfix">
    <dl class="aside-box-footerClassify">
        <dt>等级:</dt>
        <dd>
            <a href="https://blog.csdn.net/home/help.html#level" title="7级,点击查看等级说明" target="_blank">
                <svg class="icon icon-level" aria-hidden="true">
                    <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#csdnc-bloglevel-7"></use>
                </svg>
            </a>
        </dd>
    </dl>
    <dl title="5330">
        <dt>周排名:</dt>
        <dd>
            <a class="grade-box-rankA" href="https://blog.csdn.net/rank/writing_rank" target="_blank">
                5330                </a>
        </dd>
    </dl>
    <dl>
        <dt>积分:</dt>
        <dd title="16498">
            1万+            </dd>
    </dl>
    <dl title="1321">
        <dt>总排名:</dt>
        <dd>
            <a class="grade-box-rankA" href="https://blog.csdn.net/rank/writing_rank_total" target="_blank">
                1321                </a>
        </dd>
    </dl>
</div>
<div class="aside-box-footer">
                <div class="badge-box d-flex">
            <div class="profile-medal">勋章:</div>
            <div class="badge d-flex">
                                                                                                    <div class="icon-badge" title="勤写标兵Lv1">
                                <div class="mouse-box">
                                    <img src="https://csdnimg.cn/medal/qixiebiaobing1@120.png" alt="">
                                    <div class="icon-arrow"></div>
                                </div>
                                <div class="grade-detail-box">
                                    <div class="pos-box">
                                        <div class="left-box d-flex justify-content-center align-items-center flex-column">
                                            <img src="https://csdnimg.cn/medal/qixiebiaobing1@120.png" alt="">
                                            <p>勤写标兵Lv1</p>
                                        </div>
                                        <div class="right-box">
                                            授予每个自然周发布1篇到3篇原创IT博文的用户。本勋章将于次周周三上午根据用户上周的博文发布情况由系统自动颁发。                                            </div>
                                    </div>
                                </div>
                            </div>
                                                                                    </div>
            <script>
                (function($) {
                    setTimeout(function() {
                        $('div.icon-badge.show-moment').removeClass('show-moment');
                    }, 5000);
                })(window.jQuery)
            </script>
        </div>
            
</div>
    <div class="profile-intro-name-boxOpration">
    <div class="opt-letter-watch-box">
                        <a class="personal-watch bt-button" id="btnAttent" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">关注</a>
                </div>
    <div class="opt-letter-watch-box">
        <a class="bt-button btn-red-hollow personal-letter" href="https://im.csdn.net/im/main.html?userName=fjb2080" target="_blank" rel="noopener">私信</a>
    </div>
</div>
</div>
<div class="aside-content text-center" id="cpro_u2734133">
    <div id="kp_box_56" data-pid="56"><script data-ad-client="ca-pub-1076724771190722" async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" data-checked-head="true"></script>

热门文章

  •                 <a data-report-click="{&quot;mod&quot;:&quot;popu_541&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/4922490&quot;}" href="https://blog.csdn.net/fjb2080/article/details/4922490">
                                                QListWidget和QListWidgetItem的简单使用                    </a>
    				<p class="read">阅读数 <span>52064</span></p>
    			</li>
    						<li>
    
                    <a data-report-click="{&quot;mod&quot;:&quot;popu_541&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/15809097&quot;}" href="https://blog.csdn.net/fjb2080/article/details/15809097">
                                                c++11中的tuple(元组)                    </a>
    				<p class="read">阅读数 <span>52046</span></p>
    			</li>
    						<li>
    
                    <a data-report-click="{&quot;mod&quot;:&quot;popu_541&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/5617111&quot;}" href="https://blog.csdn.net/fjb2080/article/details/5617111">
                                                手把手教你用WinHex在NTFS分区中恢复被删除的文件(上)                    </a>
    				<p class="read">阅读数 <span>36617</span></p>
    			</li>
    						<li>
    
                    <a data-report-click="{&quot;mod&quot;:&quot;popu_541&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/6368869&quot;}" href="https://blog.csdn.net/fjb2080/article/details/6368869">
                                                QT浏览器学习之一:QWebView                    </a>
    				<p class="read">阅读数 <span>36324</span></p>
    			</li>
    						<li>
    
                    <a data-report-click="{&quot;mod&quot;:&quot;popu_541&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/fjb2080/article/details/4924395&quot;}" href="https://blog.csdn.net/fjb2080/article/details/4924395">
                                                QTreeWidget的简单使用                    </a>
    				<p class="read">阅读数 <span>28613</span></p>
    			</li>
    				</ul>
    </div>
    
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页