之前学习的都是关于顺序编程的知识,程序在任意时刻都只能执行一个步骤。线程作为我接触并发编程的第一堂课,我感觉很兴奋。
1、定义任务
实现Runnable接口并编写run()方法(线程将会执行此方法内代码)。
class LiftOff implements Runnable {
protected int countDown = 10;
private static int t...
分类:
编程语言 时间:
2014-07-30 14:53:33
阅读次数:
334
public?class?HTTPClient?
{
????private?static?final?Logger?logger?=?LoggerFactory.getLogger(HTTPClient.class);
????public?static?final?int?DEFAULT_CONN_TIMEOUT?=?10;
????...
分类:
其他好文 时间:
2014-07-29 16:11:59
阅读次数:
352
public class ThreadLocal extends Object
该类提供了线程局部 (thread-local) 变量。这些变量不同于它们的普通对应物,因为访问某个变量(通过其 get 或 set 方法)的每个线程都有自己的局部变量,它独立于变量的初始化副本。ThreadLocal 实例通常是类中的 private static 字段,它们希望将状态与某一个线程(例如,用户 ...
分类:
编程语言 时间:
2014-07-29 14:40:08
阅读次数:
286
public class DESCrypto { /// /// 初始化des实例秘钥及向量 /// /// /// private static DESCryptoServiceProvide...
分类:
其他好文 时间:
2014-07-28 21:20:54
阅读次数:
350
先建立一个table的基类:
public abstract class DbBaseTable {
private static final String TAG = "DbBaseTable";
/**
* @return the DB table name
*/
abstract String getName();
/**
* Creates the DB table ...
分类:
移动开发 时间:
2014-07-27 23:54:19
阅读次数:
478
在基类的table中加入upgrade操作:
public abstract class DbBaseTable {
private static final String TAG = "DbBaseTable";
/**
* @return the DB table name
*/
abstract String getName();
/**
* Creates th...
分类:
移动开发 时间:
2014-07-27 23:52:19
阅读次数:
387
public class Elvis { public static final Elvis INSTANCE = new Elvis(); private final int beltSize; private static final int CURRENT_YEAR = ...
分类:
编程语言 时间:
2014-07-27 23:00:59
阅读次数:
244
饿汉式:
class Single
{
// 提前做好!
private static final Single s = new Single();
// 私有化 构造函数 无法使用new 创建对象!
private Single(){}
// 对外提供接口
public static Single getInstance()
{...
分类:
其他好文 时间:
2014-07-26 15:27:12
阅读次数:
210
1. 类模板的 static 成员[不同于C#中的static]
类模板可以像任意其他类一样声明static 成员。以下代码:
template class Foo {
public:
static std::size_tcount() { return ctr; }
// other interfacemembers
private:
static std::size_tct...
分类:
编程语言 时间:
2014-07-26 02:42:56
阅读次数:
242
今天对于内存的理解 又加深了一步:
对下面代码的理解:
class Person
{
private String name="xiaohong";
private int age=23;
private static String country="CN";
{
System.out.println(name+" "+age);
}
public Person(String...
分类:
其他好文 时间:
2014-07-26 02:11:03
阅读次数:
189