1. package com.test;
  2.  
  3. public class BB extends AA{
  4.  
  5. public String bb = "bbbbb";
  6. public void gg() {
  7. System.out.println("bbgg");
  8. }
  9. public void gg1() {
  10. System.out.println("aagg");
  11. }
  12. }
  1. package com.test;
  2.  
  3. import java.util.concurrent.ExecutorService;
  4. import java.util.concurrent.Executors;
  5.  
  6. public abstract class AA extends CC{
  7. int d = 111;
  8.  
  9. public void gg() {
  10. System.out.println("aagg");
  11. }
  12. public abstract void gg1();
  13.  
  14. public void ff() {
  15. ExecutorService pool = Executors.newCachedThreadPool();
  16. for(int i = 1; i < 2;i++){
  17. pool.execute(new Runnable() {
  18. Thread thread = Thread.currentThread();
  19. public int ss = 2;
  20. public void gg() {
  21. System.out.println("Runnable gg");
  22. }
  23.  
  24. @Override
  25. public void run() {
  26. AA.this.gg();// this = com.test.AA$1。 里面有属性ss = 2,this$0 = com.test.BB。 调用的BB的gg()
  27. AA.this.gg1();// 调用的BB的gg1()
  28. }
  29. });
  30. }
  31. pool.shutdown();
  32. };
  33. public static void main(String[] args) {
  34. BB x = new BB();
  35. x.ff();
  36. }
  37. }
  1. package com.test;
  2.  
  3. public class CC {
  4. String ss = "ppp";
  5.  
  6. private void gg1() {
  7. System.out.println("sssgg1");
  8. }
  9. private void gg() {
  10. System.out.println("sssgg");
  11. }
  12. }

new Runnable中的 this的更多相关文章

  1. java线程基础巩固---策略模式在Thread和Runnable中的应用分析

    在上篇[http://www.cnblogs.com/webor2006/p/7709647.html]中已经学习了Runnable出现的好处,其实这种设计是采用的一种策略模式,所以为了进一步理解Ru ...

  2. 2017-11-29 由runnable说起Android中的子线程和主线程

    1.首先纠正一个观点,就是runnable运行在子线程中是错误的观念.runnable只是创建了一个执行任务的对象,但是它本身并不会创建一个新的子线程,Runable只是给你接口让你实现工作线程的工作 ...

  3. android 学习中的一些问题记录 主要是概念问题

    一些问题记录 应用程序 res 目录常见的目录有哪些,分别放置什么类型的资源? animator/ 和anim/ 放的都是定义动画的XML文件,两个地方的动画类型不同. color/ XML文件:定义 ...

  4. 【java并发】传统线程技术中创建线程的两种方式

    传统的线程技术中有两种创建线程的方式:一是继承Thread类,并重写run()方法:二是实现Runnable接口,覆盖接口中的run()方法,并把Runnable接口的实现扔给Thread.这两种方式 ...

  5. java中有关线程的题目

    1,看一下下面程序错误发生在哪一行! class Test implements Runnable{ public void run(Thread t){ } } 2,输出结果是什么? class T ...

  6. Android中Handler的消息处理

    关于Handler机制,能找到无数的文章.http://blog.csdn.net/jiangshitian/article/details/12525313这篇博客写得比较好,关键是图很清晰,结合H ...

  7. Callable, Runnable, Future, FutureTask

    Java并发编程之Callable, Runnable, Future, FutureTask Java中存在Callable, Runnable, Future, FutureTask这几个与线程相 ...

  8. java 子接口中定义与父接口相同的方法

    今天碰到一个很有意思的问题,在java中如果子接口中定义了与父接口中已经有的方法会发生什么事情呢?比如: interface IRunnable extends Runnable{ void run( ...

  9. 【转】Android开发中Handler的使用

    在Android开发中,我们经常会遇到这样一种情况:在UI界面上进行某项操作后要执行一段很耗时的代码,比如我们在界面上点击了一个”下载“按钮,那么我们需要执行网络请求,这是一个耗时操作,因为不知道什么 ...

随机推荐

  1. POJ2387-Till the cows come home【最短路】

    A - Til the Cows Come Home POJ - 2387 Bessie is out in the field and wants to get back to the barn t ...

  2. 2.1TF模型持久化

    目前tf只能保存模型中的variable变量,整个模型还不能保存,版本1.x 保存模型代码 import tensorflow as tf import numpy as np # Save to f ...

  3. 关于Python的集合set

    网上那么多说创建集合的语句是: >>>a=set([1,2,3]) python 3.6.3,你们真的能运行吗? 我这里报: Traceback (most recent call ...

  4. MySQL left join right join inner join

    好记性不如烂笔头 sql连接共三种:内连接,外连接,交叉连接. 内连接包含:等值连接,不等值连接,自然连接 外连接包含:左连接(左外连接),右连接(右外连接) 具体理论见我的博文http://blog ...

  5. 2015 湘潭大学程序设计比赛(Internet)H题-括号匹配

    括号匹配 Accepted : 30   Submit : 234 Time Limit : 10000 MS   Memory Limit : 65536 KB 题目描述 有一串括号(只包含&quo ...

  6. python中执行shell命令行read结果

    +++++++++++++++++++++++++++++ python执行shell命令1 os.system 可以返回运行shell命令状态,同时会在终端输出运行结果 例如 ipython中运行如 ...

  7. MySQL完全卸载方法

    1.在控制面板里把Mysql正常卸载 2.C:\Documents and Settings\All Users\Application Data\MySQL 这里还有MySQL的文件,必须要删除 注 ...

  8. vue-页面回退

    <template> <div> <button @click="goback">我是Home01</button> </di ...

  9. [py]类和实例方法/内建方法

    内建方法 dir(__builtins__) 类和实例方法对比 class person: def __init__(self, job): self.job = job name = "m ...

  10. JavaScript加强

    1.Aptana简介 Aptana是一个非常强大,开源,专注于JavaScript的Ajax开发IDE它的特性包括 1.JavaScript,JavaScript函数,HTML,CSS语言的Code  ...