在面试时候经常被问到多线程的相关问题: 今天在测试的时候发现下面的代码会抛出异常: java.lang.IllegalThreadStateException public static void main(String[] args)throws Exception{ Test_Thread temp = new Test_Thread(); Test_Thread temp1 = new Test_Thread(); Thread t = new Thread(temp); Thread t
using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows.Forms; namespace Demo { static class Program { /// <summary> /// 用于判
.NET 4.0包含的新名称空间System.Threading.Tasks,它包含的类抽象出了线程功能.任务表示应完成的某个单元的工作.这个单元的工作可以在单独的线程中运行,也可以以同步的方式启动一个任务,这需要等待主调线程.使用任务不仅可以获得一个抽象层,还可以对底层线程进行许多控制. 启动任务 1).使用TaskFactory类的实例,在其中把TaskMethod()方法传递给StartNew方法,就会立即启动任务. 1: using System; 2: using System.Col
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using System.Threading; namespace WindowsFormsApplication1 { static class Program { /// <summary> /// The main entry point for the application. /// </s
创建类Mutex.cs: using System; using System.Linq; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace Demo { public class Mutex { [DllImport("coredll.dll", EntryPoint = "CreateMutex", SetLas
本来想着用handlerpostdelay就可以实现,没想到演示后关闭应用居然报错. 后来想到是没有了activity. ((Activity)context).isFinishing() 可以传入context,再强转成activity.判断此acitvity是否存在,之后就可有去放心的弹出了. 通过sharedpreference判断是否购买. public class MyDialog { static SharedPreferences myShare; public sta