handler

Why getHandler() returns null?

时间秒杀一切 提交于 2019-12-23 07:36:41
问题 I have got following problem. I'm drawning route on mapview in separate thread like this: public void drawRoute(final MapView mapView) { new Thread(new Runnable() { public void run() { try { //Do something useful } catch (SomeException se) { Handler handler = mapView.getHandler(); handler.post(/*show error in UI thread*/) }} }).start(); } But when I get handler it returns null, although in debug mode handler returned and error message is displayed. What can the problem be? PS May be it's

C using Signals to stop child processes

烈酒焚心 提交于 2019-12-23 05:49:07
问题 My current program is creating child processes and giving them work (CPU intensive work). The main() sits there and waits for the child processes to send data via pipes (using select). What I wanted to do is when the program is processing data I could press CTRL+C to stop the child processes from working and asking the user if he wants to quit or resume work. If user wants to quit, the program would kill all the processes. If user wants to resume work, it would tell the child processes to

Spring MVC体系结构

故事扮演 提交于 2019-12-23 05:25:25
MVC设计模式 在传统的Web应用开发中,架构模式基本一致: 数据实体:POJO 数据层:DAO 业务层:Service 控制层:Servlet 表示层(页面层):JSP页面或HTML页面 这种架构模式就是MVC设计模式,它是软件工程中的一种架构模式,强制性地使软件系统的输入、处理和输出分开,把系统分为三个基本部分:模型(Model)、视图(View)、控制器(Controller) MVC模式中各部分的职责 Model :模型对象拥有最多的处理任务,是应用程序的主体部分,它负责数据逻辑(业务逻辑)的处理和实现数据库的操作。在项目中除了控制层的控制器,几乎每一个Bean组件都属于模型,比 如Service层、DAO层,以及POJO实体类 等。 View :负责格式化数据并把它们呈现给用户,包括数据展示、用户交互、数据验证、页面设计等功能。说白了就是离用户最近的、展示给人们看的,比 如HTML或者JSP页面 。 Controller :负责接收并转发请求,对请求处理之后拿到响应结果,指派要使用的视图(类似于指定Servlet跳转到不同的页面进行展示),将响应结果返回给客户端。对应的组件一般是 Servlet ,很少用JSP页面直接处理其他页面过来的请求。 JSP Model1 JSP+JavaBean 在一个项目中,如果业务流程比较简单的时候,可以把控制器的功能交给视图

asp.net Mvc学习之URL路由

时光总嘲笑我的痴心妄想 提交于 2019-12-23 04:54:20
Asp.Net MVC 的请求的执行过程粗略的来看大致是这样的: 1 WebServer 接收来自的客户端的 Request( 请求 ) 。 2 Web Application 在第一次运行的时候 (Application_Start()) 根据其中的设置代码会创建一个 RouteTable (路由表)实现 URL 到处理程序之间的映射。 3 UrlRotingModule 模块解析该请求的 URL ,并选择相关的 URL 路由。 4 MvcHandler 对象来处理该 URL 路由,创建要执行的控制器 (Controller ) 。 5 执行 Controller (即调用指定的执行方法)。 6 返回处理结果(执行 View() 方法,返回视图到浏览器)。 那么我们首先来深入了解一下 URL 路由。其实 URL 路由是 ASP.NET 3.5 MVC 框架中独立出来的一个功能,也就是说不仅仅在 MVC 中,即使是在传统的 WebForm 也可以使用它。 ------------------------------------------------------------------------------------------------------------------------------------------ 一 首先, URL 路由是如何加入到

Scripting events no longer fire when a user leaves site or closes browser even though app is still active

﹥>﹥吖頭↗ 提交于 2019-12-23 04:38:17
问题 A project I am working with implements three JAVA script "timers" from a Master Page to track the session time out and to do a "heartbeat" check. The "setTimerout" timer redirects the user to a warning page if the time out count reaches 1 and a half minutes before a session time out will occur. The two "setInterval" timers are implemented to track if the user's browser is sill active on the site. Following are several code snippets that implement the "timers" and the "Heartbeat" and

20 Alarms, sigaction(), and Reentrant System Calls

荒凉一梦 提交于 2019-12-23 00:27:41
1 Alarm Signals and SIGALRM 1.1 Setting an alarm unsigned int alarm(unsigned int seconds); 过n秒后向进程发送 SIGALARM 信号 SIGALARM 信号默认动作是 terminate # include <stdio.h> # include <stdlib.h> # include <unistd.h> # include <signal.h> # include <sys/signal.h> void alarm_handler ( int signum ) { printf ( "Buzz Buzz Buzz\n" ) ; } int main ( ) { //set up alarm handler signal ( SIGALRM , alarm_handler ) ; //schedule alarm for 1 second alarm ( 1 ) ; //do not proceed until signal is handled pause ( ) ; } 1.2 Recurring Alarms /* buzz_buzz.c*/ void alarm_handler ( int signum ) { printf ( "Buzz Buzz Buzz\n" ) ; /

19 Signals and Signal Handling

佐手、 提交于 2019-12-23 00:16:39
1 What are signals and how are they used 1.当进程接收到信号,进程会暂停,来处理信号 1.1 How we use signals 1. killall cat 杀死所有的cat程序 2.信号源与信号 信号源 信号 kill SIGTERM Ctrl-c SIGINT Ctrl-z SIGTSTP fg SIGCONT 2 The Wide World of Signals Signal Value Action Comment SIGHUP 1 Term Hangup detected on controlling terminal or death of controlling process SIGINT 2 Term Interrupt from keyboard SIGQUIT 3 Core Quit from keyboard SIGILL 4 Core Illegal Instruction SIGABRT 6 Core Abort signal from abort(3) SIGFPE 8 Core Floating point exception SIGKILL 9 Term Kill signal SIGSEGV 11 Core Invalid memory reference SIGPIPE 13 Term

linux/glibc. Can I use fprintf in signal handler?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 18:48:23
问题 Can I use fprintf(stderr) in a signal (SIGALRM) handler with glibc/linux? 回答1: No you cannot. Check the manpage signal(7) for a list of async-signal-safe functions. fprintf is not included in that list. If you don't need formatting then you can use write(STDERR_FILENO, <buf>, <buflen>) to write to stderr. 回答2: This is not safe, quoting IBM DeveloperWorks article about Signal Handling Safety Suppose the signal handler prints a message with fprintf and the program was in the middle of an

Android Chronometer own implementation

吃可爱长大的小学妹 提交于 2019-12-22 18:15:37
问题 I've developed an own implementation of a Chronometer. I did the follow: Create a Service (CronoService), that use a Runnable object that execute the thread. The Runnable will loop each 0.1 secs. Messenger Object that will receive messages from Ui to Start, Pause or Resume the Chronometer. Intent that will broadcast the time after each loop of the Runnable object. The code is: public class CronoService extends Service { public static final int PARAR = 0; public static final int EMPEZAR = 1;

了解 Spring MVC 的切入点

…衆ロ難τιáo~ 提交于 2019-12-22 18:05:10
Spring MVC 的拦截器 核心接口 HandlerInteceptor • boolean preHandle() • void postHandle() • void afterCompletion() 拦截器主要以HandlerInteceptor接口实现,在这个接口当中,有这三个方法。preHandle方法,我在方法处理前,做预处理,会返回一个boolean 类型的返回值,当我返回true的时候,进行接下来的方法处理,如果是false,终止方法的处理;在方法执行之后,会调用postHandle和afterCompletion,差异为是在方法视图呈现前后的差别,一个在前,一个在后面。 Spring MVC 的拦截器 针对 @ResponseBody 和 ResponseEntity 的情况 ResponseBodyAdvice 针对 @ResponseBody 返回 ResponseEntity 的情况,提供了一个ResponseBodyAdvice 针对异步请求的接口 在JAVA平台,实现异步调用的角色有如下三个角色:调用者,取货凭证,真实数据 异步调用就是:一个调用者在调用耗时操作,不能立即返回数据时,先返回一个取货凭证.然后在过一断时间后凭取货凭证来获取真正的数据. 如果数据将在线程间共享。例如正在写的数据以后可能被另一个线程读到