在资源的同步互斥中,生产者-消费者的含义是,系统中有很多生产者和消费者同时工作, 生产者负责 生产需要的资源,消费者消耗资源。 当消费者消费资源时,如果资源 不足,则等待。反之当生产者生产资源 时,如果资源已经满足需要,则也要等待该生产。同一时刻只能有一个生产者或消费者进行操作。
package com.qun;
public class Theaddemo {
class BreadContainer {
public static final int maxNum = 600;
private int num;
public BreadConta...
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...
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...
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...
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...
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...
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...
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...