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

在资源的同步互斥中,生产者-消费者的含义是,系统中有很多生产者和消费者同时工作, 生产者负责 生产需要的资源,消费者消耗资源。 当消费者消费资源时,如果资源 不足,则等待。反之当生产者生产资源 时,如果资源已经满足需要,则也要等待该生产。同一时刻只能有一个生产者或消费者进行操作。 package com.qun; public class Theaddemo { class BreadContainer { public static final int maxNum = 600; priv...
java | 2016-01-27 20:02 | 8556次阅读 | 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 But...
android | 2016-01-20 20:08 | 1391次阅读 | 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....
android | 2016-01-10 09:25 | 1354次阅读 | 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...
android | 2016-01-07 23:54 | 1602次阅读 | 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 stopButt...
学习档案 | 2016-01-03 15:03 | 1306次阅读 | 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(savedInstanceSta...
android | 2016-01-03 14:52 | 875次阅读 | 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("线程")...
学习档案 | 2016-01-02 19:22 | 681次阅读 | 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 andr...
android | 2016-01-01 16:41 | 928次阅读 | 0评
浏览147174次