Java 线程(生产者,消费者)

在资源的同步互斥中,生产者-消费者的含义是,系统中有很多生产者和消费者同时工作, 生产者负责 生产需要的资源,消费者消耗资源。 当消费者消费资源时,如果资源 不足,则等待。反之当生产者生产资源 时,如果资源已经满足需要,则也要等待该生产。同一时刻只能有一个生产者或消费者进行操作。 package com.qun; public class Theaddemo { class BreadContainer { public static final int maxNum = 600; private int num; public BreadConta...
java | 2016-01-27 20:02 | 阅读 9930 次 | 评论 0 条

歪胡demo

public class MainActivity extends Activity implements OnClickListener { private TextView tv; private Button bt1; private Button bt2; private Button bt3; private Button bt4; private Button bt5; private Button bt6; private Button bt7; private Button bt8; private Button bt9; pr...
android | 2016-01-20 20:08 | 阅读 2285 次 | 评论 0 条

View Canvas paint

public class MyView extends View{ private int count=0; public MyView(Context context) { super(context); } public void onDraw(Canvas canvas){ int color = 0; switch(count){ case 0: color=Color.BLUE; break; case 1: color=Color.LTGRAY; break; case 2: c...
android | 2016-01-10 09:25 | 阅读 2269 次 | 评论 0 条

SQLiteOpenHelper的使用

public class MainActivity extends AppCompatActivity { public Button firstButton; private Button secondButton; private SQLiteDB dbHelper; private final String dbName="helperdb"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedIn...
android | 2016-01-07 23:54 | 阅读 2467 次 | 评论 0 条

多线程下载2

public class DownMainActivity extends Activity { private static final int PROCESSING = 1; private static final int FAILURE = -1; private EditText pathText; // url地址 private TextView resultView; private Button downloadButton; private Button stopButton; private ProgressBar progressB...
学习档案 | 2016-01-03 15:03 | 阅读 2132 次 | 评论 0 条

android多线下载1

public class MainActivity extends Activity { private Button btn; private ProgressDialog dialog; //进度条 private MyAsyncTasck myAsyncTasck; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layo...
android | 2016-01-03 14:52 | 阅读 1708 次 | 评论 0 条

线程基础

public class MainActivity extends Activity { /*1*** 使用Thread的继承创建进程 ***/ public class MyThread extends Thread{ private int count=0; public void run(){ while(count<100){ count++; Log.i("======run=====", "count="+count); System.out.println("线程"); } } } /************使用run...
学习档案 | 2016-01-02 19:22 | 阅读 1590 次 | 评论 0 条

android bundle 简单传值

package com.example.postvalue; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; public class M...
android | 2016-01-01 16:41 | 阅读 2136 次 | 评论 0 条
浏览239352次
最新评论