自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

转载 Java -- Create a new thread

Here is a simple procedure for running a task in a separate thread:1. Place the code for the task into the "run" method of a class that implements the "Runnable" interface. That interface is very simp...

2018-06-29 20:30:12 177

转载 Java -- The Fork-Join Framework

We will discuss a simple example. Suppose we want to count how many elements of an array fulfill a particular property. We cut the array in half, compute the counts of each half, and add them up. To p...

2018-06-29 19:58:02 100

转载 Java -- Callables and Futures

A "Callable" is similar to a "Runnable", but it returns a value. The "Callable" interface is a parameterized type, with a single method "call".public interface Callable<V> { V call() throws ...

2018-06-28 15:17:17 161

转载 Java -- Older Thread-Safe Collections

Any collection class can be made thread safe by means of "synchronization wrapper":List<E> synchArrayList = Collections.synchronizedList(new ArrayList<E>());Map<K, V> synchHashMap =...

2018-06-27 15:52:18 117

转载 Java -- Parallel Array Algorithms

"Arrays.parallelSort" method can sort an array. For example,String contents = new String(Files.readAllBytes(Path.get("alice.txt")), StandardCharsets.UTF_8);String[] words = contents.split("[\\P{L}]+"...

2018-06-27 14:19:48 275

转载 Thread-Safe Collections

The "java.util.concurrent" package supplies efficient implementations for maps, sorted sets, and queues: "ConcurrentHashMap", "ConcurrentSkipListMap", "ConcurrentSkipListSet", and "ConcurrentLinkedQue...

2018-06-24 20:41:29 230

转载 Java -- Concurrent Fields

There is one other situation in which it is safe to access a thread field -- when it is declared "final" .  Considerfinal Map<String, Double> accounts = new HashMap<>();Other threads get t...

2018-06-23 16:04:55 171

转载 Java -- Blocking Queues

"BlockQueue<E>" 's common methods :The blocking queue methods fall into three categories that differ by the action they perform when the queue is full or empty. If you use the queue as a thread ...

2018-06-18 19:46:39 127

转载 Java -- Read/Write Locks

The "java.util.concurrent.locks" package defines two lock classes, the "ReentrantLock" and the "ReentrantReadWriteLock". The latter is useful when there are many threads that read from a data structur...

2018-06-17 18:40:48 138

转载 Java -- Lock Testing and Timeouts

A Thread blocks indefinitely when it calls the "lock" method to acquire a lock that is owned by another thread. You can be more cautious about acquiring a lock. The "tryLock" method tries to acquire a...

2018-06-17 18:26:20 112

转载 Java -- Thread-Local Variables

For example, the "SimpleDateFormat" class is not thread safe. Suppose we have a static variable:public static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");If two thread execu...

2018-06-17 17:43:26 146

转载 Thread-Uncaught Exception

A thread is terminated for one of two reasons:    It dies a natural death because the "run" method exits normally.    It dies abruptly because an uncaught exception terminates the "run" method.The "ru...

2018-06-17 14:14:36 254

转载 Java -- sychronized Keyword

The "Lock" and "Condition" interface give programmers a high degree of control over locking. However, in most situations, you don't need that control -- you can use a mechanism that is built into the ...

2018-06-17 14:09:23 112

转载 Thread -- Lock Objects and Condition Objects

Lock Objects :The basic outline for protecting  a code block with a "ReentrantLock" is :myLock.lock(); //a ReentrantLock objecttry { critical section} finally { myLock.unlock(); //make...

2018-06-17 12:10:44 181

转载 Thread - Race Condition

In most practical multithreaded applications, two or more threads need to share access to the same data, Whathappens if two threads have access to the same object and each calls a method that modifies...

2018-06-13 21:51:20 471

转载 Interrupting Thread

    You will find lots of published code in which the InterruptedException is squelched at a low level, like this:void mySubTask() {    try {        sleep(delay);    } catch(InterrptedException e) {} ...

2018-06-11 20:24:05 194

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除