This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import twitter | |
# http://mike.verdone.ca/twitter/ and Russel, MTSW, second edition, 2013 | |
import json, csv, time, sys | |
# == OAuth Authentication == | |
# The consumer keys can be found on your application's Details | |
# page located at https://dev.twitter.com/apps (under "OAuth settings") | |
consumer_key="" | |
consumer_secret="" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.net.*; | |
class evenSimplerEchoServer | |
{ | |
public static void main(String[] argv) throws Exception | |
{ | |
ServerSocket s = new ServerSocket(5000); | |
Socket t = s.accept();//wait for client to connect | |
InputStream b = t.getInputStream(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.net.*; | |
class evenSimplerEchoClient | |
{ | |
public static void main(String[] argv) throws Exception | |
{ | |
Socket s = new Socket("localhost",5000); | |
OutputStream p =s.getOutputStream(); | |
InputStream i = s.getInputStream(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class threads | |
{ | |
static class t1 extends Thread | |
{ | |
public void run() | |
{ | |
int i=0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
import java.awt.event.*; | |
import javax.swing.*; | |
import java.io.*; | |
import java.net.*; | |
public class evenSimplerGuiClient implements ActionListener { | |
private JTextField user = new JTextField("user",20); | |
private JTextArea server = new JTextArea("server",5,20); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.net.*; | |
class simpleMultiThreadedEchoServer | |
{ | |
public static void main(String[] argv) throws Exception | |
{ | |
ServerSocket s = new ServerSocket(5000); | |
Transaction k; | |
while (true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class counterThreadClash | |
{ | |
static Counter count = new Counter(); | |
static class t1 extends Thread | |
{ | |
public void run() | |
{ | |
for (int i=0;i<50000;i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class counterThreadSynchronized | |
{ | |
static Counter count = new Counter(); | |
static class t1 extends Thread | |
{ | |
public void run() | |
{ | |
for (int i=0;i<50000;i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Friend { | |
String name; | |
public Friend(String name) { | |
this.name = name; | |
} | |
public /* synchronized */ void waveAt(Friend f) { | |
System.out.println(name + " waves..."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.io.*; | |
import java.net.*; | |
class SynchList | |
{ | |
ArrayList <OutputStream> it; | |
SynchList() | |
{ |