自动输入用户名和密码用于telnet的shell, 哈哈

这个灰常强大,转了!

来自 http://www.chinaunix.net/jh/24/201364.html

自动输入用户名和密码用于tenlnet的shell, 哈哈

用linux的朋友且经常用配置路由器的可有福了.

今天刚刚完成, 大家多提意见
[bash]
#===========autotelnet.sh==============
#!/bin/bash
if (( $# != 1 ))
then
echo " u[......]

继续阅读

ssh总断开的解决方法

更改如下设置即可。

修改/etc/ssh/sshd_config文件,更改对应下面两行为:

ClientAliveInterval 60
ClientAliveCountMax 3

第一个表示每一分钟,从server向客户端发送一次alive检测,客户端响应。第二个表示,三次都没有回应才关闭连接。

感谢来自 http://sunnylocus.javaeye.com/blog/335670 的资料[......]

继续阅读

Java Concurrency in Practice 读书笔记 第七章

7.1  任务的取消
任务应该是可取消的:在run的外界可以让其状态从运行变为终止。

需要取消任务的场景:

1、用户取消任务,如点击了“取消”

2、时间timeout限制的任务

3、程序外部事件需要处理。

4、出错

5、关闭、退出、清理

Java中没有原生提供“停止线程”的方法,但可以使用“bool标志位+volatile”的方式来实现,注意list还是需要被锁保护的。
@ThreadSafe
public class PrimeGenerator[......]

继续阅读

7.1. Task Cancellation


7.1. Task Cancellation
An activity is cancellable if external code can move it to completion before its normal completion. There are a number of reasons why you might want to cancel an activity: 
User-requested cancellation. The user clicked on t[......]

继续阅读