-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
420 lines (305 loc) · 16.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<!DOCTYPE html>
<html lang="zh_cn">
<head>
<meta charset="utf-8">
<title>suphy' Blog</title>
<meta name="description" content="">
<meta name="author" content="suphy">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="./theme/html5.js"></script>
<![endif]-->
<!-- Le styles -->
<link href="./theme/bootstrap.min.css" rel="stylesheet">
<link href="./theme/bootstrap.min.responsive.css" rel="stylesheet">
<link href="./theme/local.css" rel="stylesheet">
<link href="./theme/pygments.css" rel="stylesheet">
</head>
<body>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href=".">suphy' Blog</a>
<div class="nav-collapse">
<ul class="nav">
<li><a href=".">首页</a></li>
<li><a href="./categories.html">分类</a></li>
<li><a href="./archives.html">归档</a></li>
<li><a href="./about.html">关于</a></li>
<li><a href="./search.html">搜索</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="content">
<div class="row">
<div class="span9">
<div class='article'>
<div class="content-title">
<a href="./tool/tool_androidstuido.html"><h1>Android Stuido 快捷键</h1></a>
2014-12-24 20:22:00
by <a class="url fn" href="./author/suphy.html">suphy</a>
</div>
<div><p>Android Stuido 快捷键</p>
<h2>查找</h2>
<ol>
<li>Cmd + K 快速定位到下一个使用该变量的地方</li>
<li>Shift + Cmd + K 快速定位到上一个使用该变量的地方</li>
<li>Ctrl + H 查找功能,全局查找</li>
<li>Shift + Cmd + G 查找变量或方法被用到的地方</li>
<li>Option + Cmd + Q, S 查找</li>
</ol>
<h2>功能</h2>
<ol>
<li>F3 , Cmd + 鼠标点击 打开声明</li>
<li>Option + / 代码提示</li>
<li>Option + Shift + / 智能类型变量完成</li>
<li>Ctrl + Option + / 类名提示</li>
<li>Cmd + / 行注释</li>
<li>Ctrl + CMD + / 快注释</li>
<li>Shift + CMD + F 格式化代码</li>
<li>CMD + I 自动行缩进</li>
<li>Shift + CMD + O 优化导入包</li>
<li>CMD + E 查看最近打开过的文件</li>
<li>CMD + Shift + E 查看最近编辑过的文件</li>
<li>double Shift:全局查找,这个查看和Ctrl + H稍稍有些不同,这个是全局文件查找</li>
<li>CMD + O 快捷查找当前类中的函数,变量</li>
</ol>
<h2>Plugin</h2>
<ol>
<li>Cmd-Shift-D 使用Dash查询方法文档</li>
</ol></div>
<hr />
</div>
<div class='article'>
<a href="./java/java_synchronized.html"><h2>Java线程同步</h2></a>
<div class= "well small"> 2014-12-24 20:20:00
by <a class="url fn" href="./author/suphy.html">suphy</a>
</div>
<div class="summary"><h1>Java线程同步</h1>
<p>@(java)[synchronized|wait|notify|notifyAll]
Author: 白万伟
Date: 2014-09-09</p>
<h3>对象锁</h3>
<blockquote>
<p>对象指的是拥有synchronized修饰的函数,或者是代码块的一个类的实例.</p>
</blockquote>
<p>当某个线程访问该类的方法或synchronized修饰的代码快时就要获得该对象的锁,其他线程就无法获得该对象的锁。
也就是说这个对象已经被前一个线程所占用,另外的线程无法得到该对象,所以该对象对应的方法也就无法访问,必须等到前一个线程释放对象锁才可能有机会得到对象锁。</p>
<ol>
<li>
<p>java中的每个对象都有一个锁,当访问某个对象的synchronized方法时,表示将该对象上锁,此时其他任何线程都无法在去访问该syncronized 方法了,直到之前的那个线程执行方法完毕后,其他线程才有可能去访问该synchronized方法。 </p>
</li>
<li>
<p>如果一个对象有多个synchronized方法,某一时刻某个线程已经进入到某个synchronzed方法,那么在该方法没有执行完毕前,其他线程无法访问该对象的任何synchronzied 方法的,但可以访问非synchronzied方法。 </p>
</li>
<li>
<p>如果synchronized方法是static的,那么当线程访问该方法时,它锁的并不是synchronized方法所在的对象,而是synchuronized方法所在对象的对应的Class对象,因为java中无论一个类有多少个对象,这些对象会对应唯一一个Class 对象,因此当线程分别访问同一个类的两个对象的static,synchronized方法时,他们的执行也是按顺序来的,也就是说一个线程先执行,一个线程后执行。 </p>
</li>
</ol>
<blockquote>
<p>在同步方法中线程间的通信主要依靠<code>wait()</code> <code>notify()</code> <code>notifyAll()</code>来实现, 而且这三个方法必须在synconized代码块中使用 ...</p></blockquote> <a class="btn btn-info xsmall" href="./java/java_synchronized.html">read more</a></div>
</div>
<div class='article'>
<a href="./android/android_priv-app.html"><h2>Anroid4.4新增/system/priv-app/目录的权限问题</h2></a>
<div class= "well small"> 2014-12-24 20:19:00
by <a class="url fn" href="./author/suphy.html">suphy</a>
</div>
<div class="summary"><h1>Anroid4.4新增/system/priv-app/目录的权限问题</h1>
<p>@(Android)[permission]</p>
<p>今天在项目中定义permission时使用了<code>android:protectionLevel="signatureOrSystem"</code>,
<code>signatureOrSystem</code>官方解释</p>
<div class="highlight"><pre><span class="n">A</span> <span class="n">permission</span> <span class="n">that</span> <span class="n">the</span> <span class="n">system</span> <span class="n">grants</span> <span class="n">only</span> <span class="n">to</span> <span class="n">applications</span> <span class="n">that</span> <span class="n">are</span> <span class="n">in</span> <span class="n">the</span> <span class="n">Android</span> <span class="n">system</span> <span class="n">image</span> <span class="n">or</span> <span class="n">that</span> <span class="n">are</span> <span class="kt">signed</span> <span class="n">with</span> <span class="n">the</span> <span class="n">same</span> <span class="n">certificate</span> <span class="n">as</span> <span class="n">the</span> <span class="n">application</span> <span class="n">that</span> <span class="n">declared</span> <span class="n">the</span> <span class="n">permission</span><span class="err">。</span>
</pre></div>
<p>该项目设置如下并且在<code>/system/app/</code>文件中:</p>
<div class="highlight"><pre><span class="c1">//AndroidManifest.xml ...</span></pre></div> <a class="btn btn-info xsmall" href="./android/android_priv-app.html">read more</a></div>
</div>
<div class='article'>
<a href="./android/BluetoothAdapter.html"><h2>BluetoothAdapter使用</h2></a>
<div class= "well small"> 2014-11-22 10:52:00
by <a class="url fn" href="./author/suphy.html">suphy</a>
</div>
<div class="summary"><h2>Android Quick Look: BluetoothAdapter</h2>
<p>Android SDK附带强大的蓝牙适配器,蓝牙api能够管理本地扫描附近的蓝牙设备,蓝牙设备之间传输数据,等等。本指导将向您展示最基本的必要步骤开始在Android SDK编程蓝牙应用程序。</p>
<h4>Step 1: Import the Bluetooth Package</h4>
<div class="highlight"><pre><span class="kn">import</span> <span class="nn">android.bluetooth.*</span><span class="o">;</span>
</pre></div>
<h4>Step 2: Set Bluetooth Permissions</h4>
<p>添加permission:</p>
<div class="highlight"><pre><span class="o"><</span><span class="n">uses</span><span class="o">-</span><span class="n">permission</span> <span class="nl">android:</span><span class="n">name</span><span class="o">=</span><span class="s">"android.permission.BLUETOOTH"</span> <span class="o">/></span>
</pre></div>
<p>对于更高级的蓝牙任务,如设置本地设备为我们将在本教程的名字,你就需要配置蓝牙管理员权限。添加以下行这样做:</p>
<div class="highlight"><pre><span class="o"><</span><span class="n">uses</span><span class="o">-</span><span class="n">permission</span> <span class="nl">android:</span><span class="n">name</span><span class="o">=</span><span class="s">"android.permission.BLUETOOTH_ADMIN"</span> <span class="o">/></span>
</pre></div>
<h4>Step 3: Access the Bluetooth Adapter ...</h4> <a class="btn btn-info xsmall" href="./android/BluetoothAdapter.html">read more</a></div>
</div>
<div class='article'>
<a href="./java/ThreadPoolExecutor.html"><h2>ThreadPoolExecutor运转机制详解</h2></a>
<div class= "well small"> 2014-11-22 10:48:00
by <a class="url fn" href="./author/suphy.html">suphy</a>
</div>
<div class="summary"><h1>ThreadPoolExecutor运转机制详解</h1>
<p>@(Java)[Thread|ThreadPool]</p>
<p>先看一下新建一个ThreadPoolExecutor的构建参数:</p>
<div class="highlight"><pre><span class="kd">public</span> <span class="nf">ThreadPoolExecutor</span><span class="o">(</span><span class="kt">int</span> <span class="n">corePoolSize</span><span class="o">,</span>
<span class="kt">int</span> <span class="n">maximumPoolSize</span><span class="o">,</span>
<span class="kt">long</span> <span class="n">keepAliveTime</span><span class="o">,</span>
<span class="n">TimeUnit</span> <span class="n">unit</span><span class="o">,</span>
<span class="n">BlockingQueue</span><span class="o"><</span><span class="n">Runnable</span><span class="o">></span> <span class="n">workQueue</span><span class="o">,</span>
<span class="n">ThreadFactory</span> <span class="n">threadFactory</span><span class="o">,</span>
<span class="n">RejectedExecutionHandler</span> <span class="n">handler</span><span class="o">)</span>
</pre></div>
<h3>具体流程如下:</h3>
<ol>
<li>
<p>当池子大小小于corePoolSize就新建线程,并处理请求</p>
</li>
<li>
<p>当池子大小等于corePoolSize,把请求放入workQueue中,池子里的空闲线程就去从workQueue中取任务并处理</p>
</li>
<li>
<p>当workQueue放不下新入的任务时,新建线程入池,并处理请求,如果池子大小撑到了maximumPoolSize就用RejectedExecutionHandler来做拒绝处理</p>
</li>
<li>
<p>另外,当池子的线程数大于corePoolSize的时候,多余的线程会等待keepAliveTime长的时间,如果无请求可处理就自行销毁</p>
</li>
</ol>
<h3>内部结构如下所示:</h3>
<p><img alt="Alt text" src="../static/images/threadpoolexecutor_1.gif" /></p>
<blockquote>
<p>从中可以发现ThreadPoolExecutor就是依靠BlockingQueue的阻塞机制来维持线程池,当池子里的线程无事可干的时候就通过workQueue.take()阻塞住。</p>
</blockquote>
<p><code>Executors</code>类使用<code>ExecutorService</code>提供了一个 <code>ThreadPoolExecutor</code>的简单实现,但 <code>ThreadPoolExecutor</code> 提供的功能远不止这些 ...</p> <a class="btn btn-info xsmall" href="./java/ThreadPoolExecutor.html">read more</a></div>
</div>
<div class='article'>
<a href="./vehicle/obd_ii_pids.html"><h2>OBD-II PIDs</h2></a>
<div class= "well small"> 2014-06-14 16:37:00
by <a class="url fn" href="./author/suphy.html">suphy</a>
</div>
<div class="summary"><h2>OBD-II PIDs</h2>
<p><a href="http://en.wikipedia.org/wiki/OBD-II_PIDs">OBD-II PIDs</a>是用于从车辆请求数据的代码,用作诊断工具。</p>
<p>名词解释:</p>
<ul>
<li>DTC: Diagnostic Trouble Codes 故障诊断码</li>
<li>HEV: hybrid electric vehicle 混合动力电动汽车</li>
<li>MIL: malfunction indicator lamp 故障指示灯</li>
<li>
<p>ECU Electronic Control Unit 电子控制单元</p>
</li>
<li>
<p>BCD: Binary-Coded Decimal 二进制码十进制数或二-十进制代码,用4位二进制数来表示1位十进制数中的0~9这10个数码</p>
</li>
</ul>
<h2>Modes:</h2>
<table>
<thead>
<tr>
<th>Mode (hex)</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>01</td>
<td>显示当前数据</td>
</tr>
<tr>
<td>02</td>
<td>显示冻结帧数据</td>
</tr>
<tr>
<td>03</td>
<td>显示存储诊断故障代码</td>
</tr>
<tr>
<td>04</td>
<td>清除诊断故障代码和存储值</td>
</tr>
<tr>
<td>05</td>
<td>测试结果,氧传感器监测</td>
</tr>
<tr>
<td>06</td>
<td>测试结果 ...</td></tr></tbody></table> <a class="btn btn-info xsmall" href="./vehicle/obd_ii_pids.html">read more</a></div>
</div>
<div class="pagination">
<ul>
<li class="prev disabled"><a href="#">← Previous</a></li>
<li class="active"><a href="./index.html">1</a></li>
<li class=""><a href="./index2.html">2</a></li>
<li class=""><a href="./index3.html">3</a></li>
<li class=""><a href="./index4.html">4</a></li>
<li class=""><a href="./index5.html">5</a></li>
<li class="next"><a href="./index2.html">Next →</a></li>
</ul>
</div>
</div>
<div class="span3">
<div class="well" style="padding: 8px 0; background-color: #FBFBFB;">
<ul class="nav nav-list">
<li class="nav-header">
Site
</li>
<li><a href="./archives.html">Archives</a>
<li><a href="./tags.html">Tags</a>
</ul>
</div>
<div class="well" style="padding: 8px 0; background-color: #FBFBFB;">
<ul class="nav nav-list">
<li class="nav-header">
Categories
</li>
<li><a href="./category/android.html">android</a></li>
<li><a href="./category/java.html">java</a></li>
<li><a href="./category/life.html">life</a></li>
<li><a href="./category/linux.html">linux</a></li>
<li><a href="./category/scm.html">Scm</a></li>
<li><a href="./category/tech.html">Tech</a></li>
<li><a href="./category/tool.html">tool</a></li>
<li><a href="./category/vehicle.html">vehicle</a></li>
</ul>
</div>
<div class="well" style="padding: 8px 0; background-color: #FBFBFB;">
<ul class="nav nav-list">
<li class="nav-header">
Links
</li>
<li><a href="https://www.google.com/ncr">Google</a></li>
<li><a href="http://python.org/">Python</a></li>
<li><a href="http://docs.getpelican.com/">Pelican</a></li>
</ul>
</div>
<div class="social">
<div class="well" style="padding: 8px 0; background-color: #FBFBFB;">
<ul class="nav nav-list">
<li class="nav-header">
Social
</li>
<li><a href="https://github.com/suphy2009">Github</a></li>
<li><a href="https://www.facebook.com/profile.php?id=100003251594803">Facebook</a></li>
<li><a href="http://www.linkedin.com/profile/view?id=273447004">Linkedin</a></li>
<li><a href="http://weibo.com/suphy2010">微博</a></li>
</ul>
</div>
</div>
</div>
</div> </div>
<footer>
<br />
<p><a href=".">suphy' Blog</a> © suphy 2012</p>
</footer>
</div> <!-- /container -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-collapse.js"></script>
<script>var _gaq=[['_setAccount','UA-47831467-1'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script'))</script>
</body>
</html>