为什么我的Thread(Runnable)一旦到达块的末尾就不会离开run()方法?
这是代码:
app.run(['$rootScope', '$state', function($rootScope, $state) {
$rootScope.$on('$stateChangeStart', function(evt, to, params) {
if (to.redirectToChild) {
evt.preventDefault();
$state.go(to.redirectToChild.state, params)
}
});
}]);
app.config([ '$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/404");
.state('customers', {
url: '/customers',
templateUrl: 'app/customer/parent.html',
redirectToChild: {
state: 'customers.list'
},
})
.state('customers.list', {
parent: 'customers',
url: '',
controller: 'customerCtrl as customer',
templateUrl: 'app/customer/index.html'
})
.state('customers.birthday', {
parent: 'customers',
url: '/birthday',
templateUrl: 'app/customer/birthday.html',
})
}]);
理想情况下,它应该正常结束,然后我的main()方法会启动其他东西:
//1 Entry point for thread with run method
public void run() {
System.out.println("Hashmaker():/run(). " + threadName + " Running " );
try {
String original = in;
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(original.getBytes());
byte[] digest = md.digest();
StringBuffer sb = new StringBuffer();
for (byte b : digest) {
sb.append(String.format("%02x", b & 0xff));
System.out.println("Hashmaker:/run(). original: " + original);
System.out.println("Hashmaker:/run(). digested(hex):" + sb.toString());
//src http://www.avajava.com/tutorials/lessons/how-do-i-generate-an-md5-digest-for-a-string.html
}
// Let the thread sleep for a while.
//Thread.sleep(7);
System.out.println("Hashmaker:/run(). Thread: " + threadName + " recieved a clear password = " + in);
//Save the hash
hash=sb.toString();
}
/*catch (InterruptedException e) {
System.out.println("Hashmaker:/run(). Thread " + threadName + " interrupted.");
} */
catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Hashmaker:/run(). Thread " + threadName + " exiting.");
}
正常情景对我来说,是:创建并启动一个线程来生成摘要MD5哈希,获取哈希,用它来提供消费者线程并强制它直到一个暴力哈希给出一个" compareTo"秘密哈希== 1.