上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 49 下一页

2017年12月8日

Java线程同步打印ABC

摘要: 需求: 三个线程,依次打印ABCABCABC.... 方案一: 使用阻塞队列,线程1从队列1获取内容打印,线程2从队列2获取内容打印,线程3从队列3中获取内容打印。线程1把B放到队列3中,线程2把C放到队列3中,线程3把A放到队列1中。 demo: demo里面防止打印太快,使用了Thread.sl 阅读全文

posted @ 2017-12-08 23:50 luckygxf 阅读(303) 评论(0) 推荐(0)

2017年11月27日

java生产者,消费者

摘要: 有很多实现的方法 使用blockingqueue实现 demo 注意: 自定义容器实现生产者消费者 备注: 阅读全文

posted @ 2017-11-27 10:26 luckygxf 阅读(327) 评论(0) 推荐(0)

2017年11月26日

java lock

摘要: 多线程访问同一个变量,不进行同步,会造成结果不一致。这里解决方案有很多,使用原子变量。加锁同步,使用synchronized同步。下面是一个lock demo,后面会分析lock实现原理。lock使用的是公平锁还是非公平锁等 阅读全文

posted @ 2017-11-26 22:21 luckygxf 阅读(158) 评论(0) 推荐(0)

2017年10月29日

Trim a Binary Search Tree

摘要: Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might 阅读全文

posted @ 2017-10-29 17:16 luckygxf 阅读(136) 评论(0) 推荐(0)

2017年10月28日

Baseball Game

摘要: You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 following types: Each round's operation is permane 阅读全文

posted @ 2017-10-28 17:21 luckygxf 阅读(195) 评论(0) 推荐(0)

Reverse Words in a String III

摘要: Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. E 阅读全文

posted @ 2017-10-28 16:37 luckygxf 阅读(123) 评论(0) 推荐(0)

Keyboard Row

摘要: Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below. Examp 阅读全文

posted @ 2017-10-28 16:23 luckygxf 阅读(166) 评论(0) 推荐(0)

2017年10月24日

Number Complement

摘要: Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given inte 阅读全文

posted @ 2017-10-24 23:56 luckygxf 阅读(130) 评论(0) 推荐(0)

Array Partition I

摘要: Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of 阅读全文

posted @ 2017-10-24 23:36 luckygxf 阅读(134) 评论(0) 推荐(0)

2017年10月22日

Merge Two Binary Trees

摘要: Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are n 阅读全文

posted @ 2017-10-22 22:15 luckygxf 阅读(156) 评论(0) 推荐(0)

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 49 下一页

导航