![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java多线程
alleni123
这个作者很懒,什么都没留下…
展开
-
Java死锁简单实例
代码转自: [url]http://leowzy.iteye.com/blog/740859[/url] [code="java"]public class DeadLocker implements Runnable { int field_1; private Object lock_1=new int[1]; int field_2; privat...原创 2013-11-24 21:07:37 · 97 阅读 · 0 评论 -
Java单例在多线程环境中的实现
参考网址如下: [url]http://xupo.iteye.com/blog/463426[/url] [url]http://www.iteye.com/topic/1121678?page=3[/url] [code="java"]package com.lj.singleton2; public class Singleton { private static S...原创 2013-11-24 21:29:11 · 78 阅读 · 0 评论 -
[转]多线程任务分配实例
[url]http://www.iteye.com/problems/100706 [/url] [code="java"]package com.lj.thread; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; import java.util.c...原创 2014-05-26 15:50:56 · 561 阅读 · 0 评论 -
timer cancel方法的一个小实例
[code="java"]package com.lj.timer; import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class MyTimer extends TimerTask { private int a; private Timer ti...原创 2014-07-21 12:14:40 · 476 阅读 · 0 评论 -
通过Thread.sleep把任务平均分配给线程按顺序执行的小例子
[code="java"]package com.lj.test.JavaSe4; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; impor...原创 2014-07-22 10:46:08 · 337 阅读 · 0 评论 -
Java多线程买票的实例
[code="java"]package com.lj.thread; public class SellThread implements Runnable { private int number; String s=new String(); SellThread(){ number=100; } @Override pu...原创 2013-10-24 16:36:52 · 492 阅读 · 0 评论 -
Java多线程wait,notify实例
[code="java"]package com.lj.thread2; public class Sample { private int number; // 实现number加1 public synchronized void increase() { while (0 != number) { try { wait()...原创 2013-10-25 11:34:16 · 160 阅读 · 0 评论 -
Java synchronized一个实例
[code="java"]package com.lj.thread7; public class FetchMoney { public static void main(String[] args) { Bank bank=new Bank(); Thread t1=new Thread(new MoneyThread(bank),"t1"); Thread...原创 2013-10-25 15:33:40 · 77 阅读 · 0 评论