s*t
2 楼
父亲,我又回忆起往日的时光
回忆起那灰黑色的田野 回忆起水牛沉默的眼睛
回忆起新翻的泥土 回忆起
你烟头明灭不定的光
当我蜷缩在角落中 呻吟
当我的肋骨 在异国冷漠的目光下
一根一根暴露出
它们脆弱的本性
啊 父亲 我隔着辽阔的大洋和群山呼唤你
让我重新骑回你宽厚结实的肩上
让我们重新坐回岸边 父亲
让我们面对故乡的河流 遥看远方
多么安全 澄清
让我重新沉浸于你所保护的童年中
让我们无所顾忌地游戏
啊 父亲 我生命回溯的源头
夕阳流出柔情的地方
请重新为我灵魂找回支撑的图腾
让我活得像人 死的像神
让我重新坚守于
这命运经年累月的艰辛之中 让我安息于
众神永恒的阴影和光芒
回忆起那灰黑色的田野 回忆起水牛沉默的眼睛
回忆起新翻的泥土 回忆起
你烟头明灭不定的光
当我蜷缩在角落中 呻吟
当我的肋骨 在异国冷漠的目光下
一根一根暴露出
它们脆弱的本性
啊 父亲 我隔着辽阔的大洋和群山呼唤你
让我重新骑回你宽厚结实的肩上
让我们重新坐回岸边 父亲
让我们面对故乡的河流 遥看远方
多么安全 澄清
让我重新沉浸于你所保护的童年中
让我们无所顾忌地游戏
啊 父亲 我生命回溯的源头
夕阳流出柔情的地方
请重新为我灵魂找回支撑的图腾
让我活得像人 死的像神
让我重新坚守于
这命运经年累月的艰辛之中 让我安息于
众神永恒的阴影和光芒
s*a
3 楼
有没有书友可以给一个非凡TXT电子书论坛 邀请码?
谢谢。
谢谢。
m*y
4 楼
我有一个production db server, 就装了sql server 2005 Enterprise Edition (包括
BI) , 是没有internet access的,但是从firewall block list有很多这个db server
企图access internet的entries. 不知道那位朋友知道怎么把这个企图access
internet的程序找出来? 谢谢!!!!!!
BI) , 是没有internet access的,但是从firewall block list有很多这个db server
企图access internet的entries. 不知道那位朋友知道怎么把这个企图access
internet的程序找出来? 谢谢!!!!!!
c*e
5 楼
如果要使用是个第三方的 library, 它的设计没有考虑 thread safety.在多线程程序
中,确保线程安全的最简单方法,是不是就是将要从 library 里调用的对象,建立在
一个 ThreadLocal 的变量里?这样就万事大吉了?不然,要很费劲,去研究那
library 内部的设计。
ThreadLocal 是不是用的很广泛?概念浅显,使用也最简单,方便。
中,确保线程安全的最简单方法,是不是就是将要从 library 里调用的对象,建立在
一个 ThreadLocal 的变量里?这样就万事大吉了?不然,要很费劲,去研究那
library 内部的设计。
ThreadLocal 是不是用的很广泛?概念浅显,使用也最简单,方便。
S*t
6 楼
c*e
8 楼
这个没有任何 thread safety 的保护,但好像是安全的。为什么?
public class ThreadLocalTest {
public static void main(String args[]) throws IOException {
Thread t1 = new Thread(new Task());
Thread t2 = new Thread( new Task());
t1.start();
t2.start();
}
public static String threadSafeFormat(Date date){
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
return formatter.format(date);
}
}
class Task implements Runnable{
@Override
public void run() {
for(int i=0; i<10; i++){
System.out.println("Thread: " + Thread.currentThread().getName()
+ " Formatted Date: " + ThreadLocalTest.threadSafeFormat(new Date()) );
}
}
}
输出:
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
public class ThreadLocalTest {
public static void main(String args[]) throws IOException {
Thread t1 = new Thread(new Task());
Thread t2 = new Thread( new Task());
t1.start();
t2.start();
}
public static String threadSafeFormat(Date date){
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
return formatter.format(date);
}
}
class Task implements Runnable{
@Override
public void run() {
for(int i=0; i<10; i++){
System.out.println("Thread: " + Thread.currentThread().getName()
+ " Formatted Date: " + ThreadLocalTest.threadSafeFormat(new Date()) );
}
}
}
输出:
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
Thread: Thread-1 Formatted Date: 16/11/2013
Thread: Thread-0 Formatted Date: 16/11/2013
g*e
10 楼
becuase new SimpleDateFormat object is created every time... Your test has
nothing to do with thread local. btw use DateTimeFormat from JodaTime, it's
so much beter, and thread safe.
()
【在 c*******e 的大作中提到】
: 这个没有任何 thread safety 的保护,但好像是安全的。为什么?
: public class ThreadLocalTest {
: public static void main(String args[]) throws IOException {
: Thread t1 = new Thread(new Task());
: Thread t2 = new Thread( new Task());
:
: t1.start();
: t2.start();
:
: }
nothing to do with thread local. btw use DateTimeFormat from JodaTime, it's
so much beter, and thread safe.
()
【在 c*******e 的大作中提到】
: 这个没有任何 thread safety 的保护,但好像是安全的。为什么?
: public class ThreadLocalTest {
: public static void main(String args[]) throws IOException {
: Thread t1 = new Thread(new Task());
: Thread t2 = new Thread( new Task());
:
: t1.start();
: t2.start();
:
: }
g*e
12 楼
你读的文章的下半部分
http://javarevisited.blogspot.com/2013/01/threadlocal-memory-le
【在 c*******e 的大作中提到】
: 这个没有任何 thread safety 的保护,但好像是安全的。为什么?
: public class ThreadLocalTest {
: public static void main(String args[]) throws IOException {
: Thread t1 = new Thread(new Task());
: Thread t2 = new Thread( new Task());
:
: t1.start();
: t2.start();
:
: }
http://javarevisited.blogspot.com/2013/01/threadlocal-memory-le
【在 c*******e 的大作中提到】
: 这个没有任何 thread safety 的保护,但好像是安全的。为什么?
: public class ThreadLocalTest {
: public static void main(String args[]) throws IOException {
: Thread t1 = new Thread(new Task());
: Thread t2 = new Thread( new Task());
:
: t1.start();
: t2.start();
:
: }
s*t
13 楼
呵呵,没有体。乱写一气
c*e
14 楼
对,因为那个 date 是个 local variable, 每次都重新创建。所以,他那个例子完全
不适合,根本就用不上 ThreadLocal, 他那个 PerThreadFormatter 完全是多余的. 贴
出他的完整例子:
/**
*
* @author
*/
public class ThreadLocalTest {
public static void main(String args[]) throws IOException {
Thread t1 = new Thread(new Task());
Thread t2 = new Thread( new Task());
t1.start();
t2.start();
}
/*
* Thread safe format method because every thread will use its own
DateFormat
*/
public static String threadSafeFormat(Date date){
DateFormat formatter = PerThreadFormatter.getDateFormatter();
return formatter.format(date);
}
}
/*
* Thread Safe implementation of SimpleDateFormat
* Each Thread will get its own instance of SimpleDateFormat which will not
be shared between other threads. *
*/
class PerThreadFormatter {
private static final ThreadLocal dateFormatHolder =
new ThreadLocal() {
/*
* initialValue() is called
*/
@Override
protected SimpleDateFormat initialValue() {
System.out.println("Creating SimpleDateFormat for Thread : " +
Thread.currentThread().getName());
return new SimpleDateFormat("dd/MM/yyyy");
}
};
/*
* Every time there is a call for DateFormat, ThreadLocal will return
calling
* Thread's copy of SimpleDateFormat
*/
public static DateFormat getDateFormatter() {
return dateFormatHolder.get();
}
}
class Task implements Runnable{
@Override
public void run() {
for(int i=0; i<100; i++){
System.out.println("Thread: " + Thread.currentThread().getName()
+ " Formatted Date: " + ThreadLocalTest.threadSafeFormat(new Date()) );
}
}
}
s
【在 g**e 的大作中提到】
: becuase new SimpleDateFormat object is created every time... Your test has
: nothing to do with thread local. btw use DateTimeFormat from JodaTime, it's
: so much beter, and thread safe.
:
: ()
不适合,根本就用不上 ThreadLocal, 他那个 PerThreadFormatter 完全是多余的. 贴
出他的完整例子:
/**
*
* @author
*/
public class ThreadLocalTest {
public static void main(String args[]) throws IOException {
Thread t1 = new Thread(new Task());
Thread t2 = new Thread( new Task());
t1.start();
t2.start();
}
/*
* Thread safe format method because every thread will use its own
DateFormat
*/
public static String threadSafeFormat(Date date){
DateFormat formatter = PerThreadFormatter.getDateFormatter();
return formatter.format(date);
}
}
/*
* Thread Safe implementation of SimpleDateFormat
* Each Thread will get its own instance of SimpleDateFormat which will not
be shared between other threads. *
*/
class PerThreadFormatter {
private static final ThreadLocal
new ThreadLocal
/*
* initialValue() is called
*/
@Override
protected SimpleDateFormat initialValue() {
System.out.println("Creating SimpleDateFormat for Thread : " +
Thread.currentThread().getName());
return new SimpleDateFormat("dd/MM/yyyy");
}
};
/*
* Every time there is a call for DateFormat, ThreadLocal will return
calling
* Thread's copy of SimpleDateFormat
*/
public static DateFormat getDateFormatter() {
return dateFormatHolder.get();
}
}
class Task implements Runnable{
@Override
public void run() {
for(int i=0; i<100; i++){
System.out.println("Thread: " + Thread.currentThread().getName()
+ " Formatted Date: " + ThreadLocalTest.threadSafeFormat(new Date()) );
}
}
}
s
【在 g**e 的大作中提到】
: becuase new SimpleDateFormat object is created every time... Your test has
: nothing to do with thread local. btw use DateTimeFormat from JodaTime, it's
: so much beter, and thread safe.
:
: ()
S*t
15 楼
自由体:)
c*1
17 楼
你的诗里目前最喜欢这首,呵呵,很棒!
相关阅读
大家写java class的时候是完全封装的么?求中文JAVA入门书籍OCEF海外教育基金会寻找义工System Administrator要从WINDOWS转移到LINUX环境了大家在工作中遇到过什么很难的问题(技术上) 可以用Java 做机器人吗?再问generic问题:tomcat编译错误Good Design forums?请帮忙看看这个编译错误Jboss Failover (unplug network cable)LIGHTWEIGHT_RENDERER in all-java JMF.jit编译器?struts 问题求教java编译命令的重复执行问题?9191Java比C++快的理论依据(ZT)J2EE 的面试程序How to set tab set of PRE in JEditorPane?how to use xde with wasd 5多个Log4J配置文件问题