public
Created

Some code it isn't reasonable to expect to run in a notebook?

  • Download Gist
SillyThreading.ipynb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
{
"metadata": {
"name": "SneakyThreading"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"import threading\n",
"import time\n",
"\n",
"class counterThread(threading.Thread):\n",
" def run(self):\n",
" for i in range(5):\n",
" time.sleep(2)\n",
" print i"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"for i in (1, 2, 3):\n",
" counterThread().start()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"4\n",
"4\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"0\n",
"0\n",
"0\n",
"1"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"1\n",
"1\n",
"2"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"2\n",
"2\n",
"3"
]
}
],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\n",
"3\n",
"3\n"
]
}
],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.