摘要: 静态方法: String与其他数据类型之间的转换: int → String: String s = String.valueOf(int i) Stirng → int: int i = Integer.parseInt( s ); 方法: 1.string.trim()---去掉两端空格 2.s 阅读全文
posted @ 2014-03-19 19:50 rhythm of the rain 阅读(389) 评论(0) 推荐(0)
摘要: 1.static(用static修饰的方法或属性属于类,属于对象) 修饰属性:属于类而不属于对象,存在内存中的数据区,多个对象共享此属性。注意在继承的时候,父类中的static属性子类也共享。 修饰方法:可以由类直接调用,不用new对象。 修饰语句块:在classloader加载类的时候执行(new 阅读全文
posted @ 2014-03-19 15:26 rhythm of the rain 阅读(130) 评论(0) 推荐(0)
摘要: 1.wait()和notify()是Object类中的final方法。 2.只有在synchronized中才能调用wait()和notify()方法。 3.调用wait()是当前线程让出资源进行等待,notify()随机唤醒一个wait()状态的线程,与其他线程重新进行排队。当重新获取到执行机会时 阅读全文
posted @ 2014-03-11 10:11 rhythm of the rain 阅读(133) 评论(0) 推荐(0)
摘要: synchronized有两种方式: 1.写在方法前(相当于锁定当前对象) 2.synchronized(object){} 注意: 1.被锁住的对象在锁外面是可以被修改的,所以要注意synchronized的位置。 2.当两个不同的锁锁住相同的对象时,只能有一个线程在执行其中一个锁。(实际上就是一 阅读全文
posted @ 2014-03-10 19:57 rhythm of the rain 阅读(169) 评论(0) 推荐(0)
摘要: 一、创建线程 1、继承java.lang.Thread类 重写run()方法。 2、实现java.lang.Runnable接口 实现run()方法 二、启动线程 1、调用start()方法,而不是run()或者别的方法。 2、通过实现Runnable接口创建的线程没有start()方法,需要利用T 阅读全文
posted @ 2014-03-10 14:48 rhythm of the rain 阅读(224) 评论(0) 推荐(0)