You can use strace on a specific pid to figure out what a specific process is doing, e.g.:
strace -fp <pid>
You might see something like:
select(9, [3 5 8], [], [], {0, 999999}) = 0 (Timeout)
import urllib2 | |
import json | |
import time | |
# Form: http://digitalpbk.com/stock/google-finance-get-stock-quote-realtime | |
class GoogleFinanceAPI: | |
def __init__(self): | |
self.prefix = "http://finance.google.com/finance/info?client=ig&q=" | |
def get(self,symbol,exchange): |
(ns pallet.cache.impl | |
"An implementation namespace for pallet.cache") | |
(defprotocol CacheProtocolImpl | |
"Cache implementation interface." | |
(lookup [cache e] [cache e default] | |
"Retrieve the value associated with `e` if it exists") | |
(has? [cache e] | |
"Checks if the cache contains a value associtaed with `e`")) |
public class OAuthActivity extends Activity { | |
public static String OAUTH_URL = "https://github.com/login/oauth/authorize"; | |
public static String OAUTH_ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token"; | |
public static String CLIENT_ID = "YOUR_CLIENT_ID"; | |
public static String CLIENT_SECRET = "YOUR_CLIENT_SECRET"; | |
public static String CALLBACK_URL = "http://localhost"; | |
@Override |
package controllers | |
import lib._ | |
import play.api.mvc._ | |
import play.api.libs.json._ | |
object Auth extends Controller { | |
val GITHUB = new OAuth2[GithubUser](OAuth2Settings( |
function loadenv() { | |
env=${1:-.env} | |
echo Loading $env | |
file=`mktemp -t tmp` | |
if [ -f $env ]; then | |
cat $env | while read line; do | |
echo export $line >> $file | |
done | |
source $file | |
else |
Asynchronicity is the price to pay, you better know what you're paying for...
Let's share some vocabulary first:
Thread: The primitive responsible of executing code on the processor, you can give an existing (or a new) Thread some code, and it will execute it. Normally you can have a few hundreds on a JVM, arguments that you can tweak your way out to thousands. Worth noting that multitasking is achieved when using multiple Threads. Multiple Threads can exist for a single processor in which case multitasking happens when this processor switches between threads, called context switching, which will give the impression of things happenning in parallel. An example of a direct, and probably naive, use of a new Thread in Java:
public class MyRunnable implements Runnable {
public void run(){
System.out.println("MyRunnable running");
<!-- ... --> | |
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> | |
<uses-permission android:name="android.permission.INTERNET" /> | |
<uses-permission android:name="android.permission.USE_CREDENTIALS" /> | |
<!-- ... --> |