C/C++/JAVA
文章平均质量分 92
我把葡萄酿成酒
吾日三省吾身
展开
-
Java的一些小问题
1. Java new一个数组的方式For primitive types:int[] myIntArray = new int[3];int[] myIntArray = {1,2,3};int[] myIntArray = new int[]{1,2,3};For classes, for example String, it's thesame:String[]原创 2015-05-09 11:39:54 · 396 阅读 · 0 评论 -
C++中的智能指针
Smart pointersSmart pointers enable automatic, exception-safe, object lifetime management. Defined in header Pointer categories 1. unique_ptr (C++11) smart pointer with unique object ownership semant原创 2016-09-01 21:30:53 · 440 阅读 · 0 评论 -
Static
初始化原创 2016-08-22 10:03:31 · 304 阅读 · 0 评论 -
Exception
Exception and Final原创 2016-08-22 09:37:30 · 260 阅读 · 0 评论 -
Java Doc
并发相关的声明 1. GuardedBy The field or method to which this annotation is applied can only be accessed when holding a particular lock, which may be a built-in (synchronization) lock, or may be an explic原创 2016-08-18 15:27:39 · 366 阅读 · 0 评论 -
Thread
run vs startrun() If this thread was constructed using a separate Runnable run object, then that Runnable object’s run method is called; otherwise, this method does nothing and returns. start() Caus原创 2016-08-17 18:03:59 · 403 阅读 · 0 评论 -
BlockingQueue
java.util.concurrentInterface BlockingQueueType Parameters: E - the type of elements held in this collectionAll Superinterfaces: Collection, Iterable, QueueAll Known Subinterfaces: BlockingDeque, Tr原创 2016-08-17 14:59:53 · 279 阅读 · 0 评论 -
ExecutorService and Future
public interface ExecutorServiceextends Executor An Executor that provides methods to manage termination and methods that can produce a Future for tracking progress of one or more asynchronous tasks.原创 2016-08-17 14:44:12 · 315 阅读 · 0 评论 -
ReentrantLock
public class ReentrantLockextends Object implements Lock, SerializableA reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor lock accessed using synchroni原创 2016-08-17 13:39:23 · 327 阅读 · 0 评论 -
Java的并发问题总结
前言java多线程分类中写了21篇多线程的文章,21篇文章的内容很多,个人认为,学习,内容越多、越杂的知识,越需要进行深刻的总结,这样才能记忆深刻,将知识变成自己的。这篇文章主要是对多线程的问题进行总结的,因此罗列了40个多线程的问题。这些多线程的问题,有些来源于各大网站、有些来源于自己的思考。可能有些问题网上有、可能有些问题对应的答案也有、也可能有些各位网友也都看过,但是本文写作的重心就转载 2016-06-28 20:03:12 · 2632 阅读 · 0 评论 -
Android各层打印栈的方法
1. #include 2. 在函数内插入这么一段{ CallStack stack; stack.update(); stack.log("XXXXXX",ANDROID_LOG_ERROR);}其中“XXXXXX”指的是TAG原创 2015-08-23 20:30:03 · 541 阅读 · 0 评论 -
强指针和弱指针
1 强指针和弱指针1.1 指针问题指针是c,c++语言中的一件大杀器,功能强大,但却很容易造成非常难以解决的bug。我们经常遇到的指针问题有: 1. malloc的内存没有free,这样造成了内存泄露 2. 已经delete的指针还在使用,这种就是所谓“野指针”,即指针没有指向一个活着的对象。比如:class A{public: i原创 2015-08-30 19:09:20 · 9862 阅读 · 0 评论 -
关于JNI
1. 使用/****/package com.magc.jni;/*** @author magc**/public class HelloWorld { static { System.loadLibrary("Hello"); } public native void DisplayHe原创 2015-07-19 23:01:11 · 343 阅读 · 0 评论 -
Java中的final
final和abstract不能同时使用1. final可以修饰类,方法和变量。修饰类的时候,表示该类无法被继承,final类的方法默认是final的2. final方法不能被覆盖3. final变量赋值后无法更改使用final修饰方法的好处:1. 锁定final,使得继承类无法修改它的实现2. 编译器在遇到final方法时会转入内嵌机制,大大提高执行效率原创 2015-07-19 22:58:32 · 376 阅读 · 0 评论 -
Java中的static
1. static 变量2. static 方法静态方法只能访问静态的变量和方法,不能出现this,super等关键字3. static 代码块在类加载时调用的。。。。但是啥是类加载的时候啊?例子,在RCSApp中,static { System. loadLibrary("lemon"); SdkLogger. Log(原创 2015-07-19 22:59:35 · 335 阅读 · 0 评论 -
#pragma pack
为什么要对齐?因为存取效率的问题if#pragma pack(1), no paddingHere is a post from StackOverflow#pragma pack instructs the compiler to pack structure members with particular alignment. Most compil原创 2015-07-19 22:55:09 · 402 阅读 · 0 评论 -
C中的移位运算
1. 左移,木有问题,在右边补0右移,分为逻辑右移和算术右移逻辑右移在左端补0,算术右移在左端补符号位。例如:x>>4逻辑右移 01100011->00000110 10010101->00001001算术右移 01100011->00000110 10010101->11111001几乎所原创 2015-07-19 22:53:25 · 422 阅读 · 0 评论 -
Bitmap & Bitset
class Bitmap { public: explicit Bitmap(const int size) : size_(size), num_words_((size + 31) / 32) { words_.resize(size); Reset(); }~Bitmap() {}int size() const { return size_;原创 2016-09-02 18:42:30 · 1389 阅读 · 0 评论